diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ec9197d..161fd94 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,7 +28,7 @@ jobs: run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 with: file: ./coverage.txt token: ${{ secrets.CODECOV_TOKEN }} @@ -51,8 +51,8 @@ jobs: go-version: ${{ matrix.go-version }} - name: golangci-lint - uses: golangci/golangci-lint-action@v4 + uses: golangci/golangci-lint-action@v8 with: version: latest - args: --timeout=5m --out-format=colored-line-number + args: --output.text.colors=true --output.text.print-linter-name=true --output.text.print-issued-lines=true only-new-issues: true diff --git a/.golangci.yaml b/.golangci.yaml index 0473d93..3abc648 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,26 +1,25 @@ -# More info on config here: https://golangci-lint.run/usage/configuration/#config-file +version: "2" + run: + timeout: 5m concurrency: 8 - timeout: 10m issues-exit-code: 1 tests: true output: formats: - - format: colored-line-number - path: stdout - - format: html - path: tmp/linter-report-backend.html + text: + path: stdout + html: + path: tmp/linter-report-backend.html linters: - disable-all: true + default: none enable: - errcheck - gocognit - goconst - - goimports - gosec - - gosimple - govet - ineffassign - lll @@ -29,64 +28,71 @@ linters: - perfsprint - revive - staticcheck - - stylecheck - - typecheck - unused + settings: + dupl: + threshold: 100 + gocognit: + min-complexity: 30 + goconst: + min-len: 2 + min-occurrences: 2 + govet: + disable: + - fieldalignment + - printf + - shadow + enable-all: true + lll: + line-length: 120 + nlreturn: + block-size: 5 + perfsprint: + int-conversion: true + err-error: true + errorf: true + sprintf1: true + strconcat: true + exclusions: + generated: lax + rules: + - path: (.+)\.go$ + text: G104 + - path: (.+)\.go$ + text: exported func .* returns unexported type .*, which can be annoying to use + - path: (.+)\.go$ + text: should have a package comment + - path: (.+)\.go$ + text: don't use an underscore in package name + paths: + - \.pb\.go$ + - \.pb\.gw\.go$ + - _test\.go$ + - bin + - vendor + - var + - tmp + - mocks + - \.cache + - third_party$ + - builtin$ + - examples$ -linters-settings: - govet: - enable-all: true - disable: - # There is rarely performance differences due to padding, - # the most noticable impact is memory usage. However, - # the main trace data is Protobuf-generated and we ignore - # those files from linting, so this linter is not useful. - - fieldalignment - # Disable shadow - - printf - - shadow - dupl: - threshold: 100 - gocognit: - min-complexity: 30 - goconst: - min-len: 2 - min-occurrences: 2 - lll: - line-length: 120 - perfsprint: - # Optimizes even if it requires an int or uint type cast. - int-conversion: true - # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. - err-error: true - # Optimizes `fmt.Errorf`. - errorf: true - # Optimizes `fmt.Sprintf` with only one argument. - sprintf1: true - # Optimizes into strings concatenation. - strconcat: true - nlreturn: - # Size of the block (including return statement that is still "OK") - # so no return split required. - # Default: 1 - block-size: 5 - -issues: - exclude-use-default: false - exclude: - # _ instead of err checks - - G104 - - exported func .* returns unexported type .*, which can be annoying to use - - should have a package comment - - don't use an underscore in package name - exclude-dirs: - - bin - - vendor - - var - - tmp - - mocks - - \.cache - exclude-files: - - \.pb\.go$ - - \.pb\.gw\.go$ - - _test\.go$ +formatters: + enable: + - goimports + exclusions: + generated: lax + paths: + - \.pb\.go$ + - \.pb\.gw\.go$ + - _test\.go$ + - bin + - vendor + - var + - tmp + - mocks + - \.cache + - third_party$ + - builtin$ + - examples$ diff --git a/go.mod b/go.mod index 05d2ba3..94647fb 100644 --- a/go.mod +++ b/go.mod @@ -1,16 +1,16 @@ module github.com/8thgencore/valchemy -go 1.24.0 +go 1.24.5 require ( - github.com/alecthomas/kong v1.8.1 - github.com/golang-cz/devslog v0.0.11 + github.com/alecthomas/kong v1.12.0 + github.com/golang-cz/devslog v0.0.15 github.com/ilyakaznacheev/cleanenv v1.5.0 github.com/stretchr/testify v1.10.0 ) require ( - github.com/BurntSushi/toml v1.4.0 // indirect + github.com/BurntSushi/toml v1.5.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/joho/godotenv v1.5.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect diff --git a/go.sum b/go.sum index a1ca417..72af24d 100644 --- a/go.sum +++ b/go.sum @@ -1,16 +1,20 @@ github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= -github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg= +github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/kong v1.8.1 h1:6aamvWBE/REnR/BCq10EcozmcpUPc5aGI1lPAWdB0EE= -github.com/alecthomas/kong v1.8.1/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.10.0 h1:8K4rGDpT7Iu+jEXCIJUeKqvpwZHbsFRoebLbnzlmrpw= +github.com/alecthomas/kong v1.10.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.12.0 h1:oKd/0fHSdajj5PfGDd3ScvEvpVJf9mT2mb5r9xYadYM= +github.com/alecthomas/kong v1.12.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/golang-cz/devslog v0.0.11 h1:v4Yb9o0ZpuZ/D8ZrtVw1f9q5XrjnkxwHF1XmWwO8IHg= -github.com/golang-cz/devslog v0.0.11/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= +github.com/golang-cz/devslog v0.0.13 h1:JkJ6PPNSOCBpYyU03v3xw7WgpChQ3AYFqgRbYBhUk/Y= +github.com/golang-cz/devslog v0.0.13/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= +github.com/golang-cz/devslog v0.0.15 h1:ejoBLTCwJHWGbAmDf2fyTJJQO3AkzcPjw8SC9LaOQMI= +github.com/golang-cz/devslog v0.0.15/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= github.com/ilyakaznacheev/cleanenv v1.5.0 h1:0VNZXggJE2OYdXE87bfSSwGxeiGt9moSR2lOrsHHvr4= diff --git a/internal/replication/replica.go b/internal/replication/replica.go index f8b8bc5..24e53d6 100644 --- a/internal/replication/replica.go +++ b/internal/replication/replica.go @@ -40,7 +40,7 @@ func (m *Manager) maintainMasterConnection() error { m.conn = nil } - replicationAddress := fmt.Sprintf("%s:%s", m.cfg.MasterHost, m.cfg.ReplicationPort) + replicationAddress := net.JoinHostPort(m.cfg.MasterHost, m.cfg.ReplicationPort) var err error retryCount := m.cfg.SyncRetryCount diff --git a/taskfiles/deps.yml b/taskfiles/deps.yml index c54b5d7..a79678f 100644 --- a/taskfiles/deps.yml +++ b/taskfiles/deps.yml @@ -6,6 +6,6 @@ tasks: cmds: - go install github.com/air-verse/air@latest - go install github.com/pressly/goose/v3/cmd/goose@latest - - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest - go install mvdan.cc/gofumpt@latest - go install github.com/yoheimuta/protolint/cmd/protolint@latest + - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.2.1