Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions .github/workflows/static-checks-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
name: Static Checks - Go

on:
push:
branches:
- main
paths:
- '**/go.*'
- '**.go'
pull_request:
paths:
- '**/go.*'
Expand All @@ -28,13 +22,12 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
go-version: '1.23'

- name: Test
run: make go-test

- name: Vet
run: make go-vet

- name: Staticcheck
run: make go-staticcheck
- name: Lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# But not these files...
!/.gitignore
!/.golangci.yml

!*.go
!go.sum
Expand Down
13 changes: 13 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
linters:
# Disable all linters.
# Default: false
disable-all: true

enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
golang 1.22.4
golang 1.23.1
30 changes: 4 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,14 @@ go-fmt:
$(info Go formatting...)
gofmt -d -s -w .

.PHONY: go-mod-tidy
go-mod-tidy:
$(info Tidying module...)
go mod tidy

.PHONY: go-staticcheck
go-staticcheck:
$(info Running go-staticcheck...)
go install honnef.co/go/tools/cmd/staticcheck@latest
staticcheck -go 1.22 ./...

.PHONY: go-staticcheck-no-install
go-staticcheck-no-install:
$(info Running go-staticcheck...)
staticcheck -go 1.22 ./...
.PHONY: go-lint
go-lint:
golangci-lint run

.PHONY: go-test
go-test:
$(info Running tests...)
go test ./...

.PHONY: go-update-deps
go-update-deps:
$(info Updating dependencies...)
go get -u ./...

.PHONY: go-vet
go-vet:
$(info Vetting...)
go vet ./...

.PHONY: local-dev-all
local-dev-all: go-fmt go-test go-vet go-staticcheck
local-dev-all: go-fmt go-test go-lint
14 changes: 11 additions & 3 deletions childproc/childproc.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,24 @@ func stopChildProcess(l logger.Logger, cfg runtimeconfig.Config, st *state) erro
l.Errorf(logger.INFO, "Stopping child process")
st.currentProcState = procStateStopping
shutdownStaredAt := time.Now()
success := func() error {
st.currentProcState = procStateNotStarted
l.Errorf(logger.DEBUG, "Child process quit in %s", time.Since(shutdownStaredAt))
return nil
}
isSigint := cfg.QuitSignal() == syscall.SIGINT
if err := st.cmd.Process.Signal(cfg.QuitSignal()); err != nil {
return fmt.Errorf("sending signal to child process: %w", err)
} else if st.cmd == nil {
return errors.New("child process should not be nil")
} else if err := st.cmd.Wait(); err != nil {
if isSigint && strings.Contains(err.Error(), "signal: interrupt") {
l.Errorf(logger.DEBUG, "Child process quit with SIGINT")
return success()
}
return fmt.Errorf("waiting for child process to finish: %w", err)
} else {
st.currentProcState = procStateNotStarted
l.Errorf(logger.DEBUG, "Child process quit in %s", time.Since(shutdownStaredAt))
return nil
return success()
}
} else if st.currentProcState == procStateNotStarted {
l.Errorf(logger.WARNING, "Current process state: not started")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/jakewan/go-procrotator

go 1.22.4
go 1.23.1

require (
github.com/BurntSushi/toml v1.4.0
Expand Down