Skip to content

Commit

Permalink
Upgrade go and golangci lint (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbindreiter authored Feb 14, 2025
1 parent ec79f1f commit ac568b1
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 125 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
os: [Ubuntu]
go-version: ["1.23.x"]
go-version: ["1.24.x"]
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -42,4 +42,4 @@ jobs:
- name: Lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.62.0
version: v1.64.5
77 changes: 68 additions & 9 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
run:
timeout: '5m'
linters-settings:
errcheck:
ignore: "" # https://github.com/golangci/golangci-lint/issues/4733
gosec:
excludes:
- G601 # Not relevant anymore with Go 1.22 and later
Expand All @@ -26,67 +24,128 @@ linters-settings:
- - skipPackageNameChecks: true
stylecheck:
checks: ["all", "-ST1003"]
tagalign:
order: ["flag", "env", "default", "secret", "toml", "json", "validate", "global", "help"]
strict: false
linters:
enable:
enable: # list taken from https://golangci-lint.run/usage/linters/ - last updated 2025-02-14 for v1.64.5
# enabled by default, but list them here to be explicit
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
# other linters (that would be disabled by default)
- asasalint # checks for pass []any as any in variadic func(...any)
- asciicheck # checks that your code does not contain non-ASCII identifiers
- bidichk # checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- canonicalheader # checks for canonical names in HTTP headers
- copyloopvar # detects places where loop variables are copied
- containedctx # detects struct contained context.Context field
#- contextcheck # checks for inherited context.Context
- copyloopvar # detects places where loop variables are copied
#- cyclop # checks function and package cyclomatic complexity
- dupl # tool for code clone detection
- decorder # check declaration order and count of types, constants, variables and functions
#- depguard # Go linter that checks if package imports are in a list of acceptable packages
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
#- dupl # tool for code clone detection
- dupword # checks for duplicate words in the source code
- durationcheck # checks for two durations multiplied together
#- err113 # checks the errors handling expressions
- errchkjson # checks types passed to the json encoding functions.
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
- exhaustive # checks exhaustiveness of enum switch statements
#- exhaustruct # checks if all structure fields are initialized
- exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions.
- fatcontext # finds nested context.WithValue calls in loops
- forbidigo # forbids identifiers
#- forcetypeassert # finds forced type assertions
#- funlen # Tool for detection of long functions
- gci # Checks if code and import statements are formatted, with additional rules.
#- ginkgolinter # Enforces the Ginkgo testing package guidelines.
- gocheckcompilerdirectives # validates go compiler directive comments (//go:)
#- gochecknoglobals # checks that no global variables exist
- gochecknoinits # checks that no init functions are present in Go code
- gochecksumtype # checks exhaustiveness on Go "sum types"
#- gocognit # Computes and checks the cognitive complexity of functions
- goconst # finds repeated strings that could be replaced by a constant
- gocritic # provides diagnostics that check for bugs, performance and style issues
- goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt
#- gomnd # detects magic numbers
#- gocyclo # Computes and checks the cyclomatic complexity of functions
#- godot # Check if comments end in a period
#- godox # Tool for detection of FIXME, TODO and other comment keywords
- gofmt # Checks if the code is formatted according to 'gofmt' command
- gofumpt # Checks if code and import statements are formatted, with additional rules
#- goheader # Checks is file header matches to pattern
- goimports # Checks if the code and import statements are formatted according to the 'goimports' command.
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
- gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations
- goprintffuncname # checks that printf-like functions are named with f at the end
- gosec # inspects source code for security problems
- gosmopolitan # Report certain i18n/l10n anti-patterns in your Go codebase.
- grouper # Analyze expression groups
- iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution.
- importas # Enforces consistent import aliases.
#- inamedparam # Reports interfaces with unnamed method parameters.
- interfacebloat # Checks the number of methods in an interface
- intrange # finds places where for loops could make use of an integer range
#- ireturn # Accept Interfaces, Return Concrete Types
#- lll # Reports long lines
- loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap)
#- maintidx # measures the maintainability index of each function
- makezero # finds slice declarations with non-zero initial length
- mirror # reports wrong mirror patterns of bytes/strings usage
- misspell # finds commonly misspelled English words in comments
#- mnd # Detects magic numbers
- musttag # enforces field tags in (un)marshaled structs
- nakedret # finds naked returns in functions greater than a specified function length
#- nestif # Reports deeply nested if statements
- nilerr # finds the code that returns nil even if it checks that the error is not nil
- nilnesserr # Reports constructs that checks for err != nil, but returns a different nil value error.
- nilnil # checks that there is no simultaneous return of nil error and an invalid value
#- nlreturn # Checks for a new line before return and branch statements to increase code clarity
- noctx # finds sending http request without context.Context
- nolintlint # reports ill-formed or insufficient nolint directives
- nonamedreturns # reports all named returns
- nosprintfhostport # checks for misuse of Sprintf to construct a host with port in a URL
- perfsprint # checks that fmt.Sprintf can be replaced with a faster alternative
#- paralleltest # detects missing usage of t.Parallel() method in your Go test
- perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative.
- prealloc # finds slice declarations that could potentially be preallocated
- predeclared # finds code that shadows one of Go's predeclared identifiers
- promlinter # checks Prometheus metrics naming via promlint
- protogetter # reports direct reads from proto message fields when getters should be used
- reassign # checks that package variables are not reassigned
- recvcheck # checks for receiver type consistency
- revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint
- rowserrcheck # checks whether Err of rows is checked successfully
- sloglint # ensure consistent code style when using log/slog
- spancheck # checks for mistakes with OpenTelemetry/Census spans
- sqlclosecheck # checks that sql.Rows and sql.Stmt are closed
- stylecheck # is a replacement for golint
- tagalign # checks that struct tags are well aligned
- tenv # detects using os.Setenv instead of t.Setenv since Go1.17
- testableexamples # checks if examples are testable (have an expected output)
#- tagliatelle # Checks the struct tags.
#- testableexamples # checks if examples are testable (have an expected output)
- testifylint # checks usage of github.com/stretchr/testify
#- testpackage # makes you use a separate _test package
#- thelper # detects golang test helpers without t.Helper() call.
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
- unconvert # removes unnecessary type conversions
- unparam # reports unused function parameters
- usestdlibvars # detects the possibility to use variables/constants from the Go standard library
- usetesting # reports uses of functions with replacement inside the testing package
#- varnamelen # checks that the length of a variable's name matches its scope
- wastedassign # finds wasted assignment statements
- whitespace # detects leading and trailing whitespace
#- wrapcheck # Checks that errors returned from external packages are wrapped
#- wsl # whitespace linter - add or remove empty lines
#- zerologlint # checks wrong usage of zerolog
#- tenv # deprecated in favor of usetesting
issues:
exclude-rules:
# Exclude some linters from running on tests files.
- path: '_test.go'
linters:
- containedctx
- dogsled
9 changes: 0 additions & 9 deletions datasets/v1/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func (s *service) GetDataset(ctx context.Context, slug string) (*datasetsv1.Data
Slug: slug,
},
))

if err != nil {
return nil, fmt.Errorf("failed to get dataset: %w", err)
}
Expand All @@ -64,7 +63,6 @@ func (s *service) ListDatasets(ctx context.Context) (*datasetsv1.ListDatasetsRes
ClientInfo: clientInfo(),
},
))

if err != nil {
return nil, fmt.Errorf("failed to list datasets: %w", err)
}
Expand Down Expand Up @@ -104,7 +102,6 @@ func (s *service) CreateCollection(ctx context.Context, datasetID uuid.UUID, col
Name: collectionName,
},
))

if err != nil {
return nil, fmt.Errorf("failed to create collection: %w", err)
}
Expand All @@ -124,7 +121,6 @@ func (s *service) GetCollections(ctx context.Context, datasetID uuid.UUID) (*dat
WithCount: true,
},
))

if err != nil {
return nil, fmt.Errorf("failed to get collections: %w", err)
}
Expand All @@ -145,7 +141,6 @@ func (s *service) GetCollectionByName(ctx context.Context, datasetID uuid.UUID,
},
},
))

if err != nil {
return nil, fmt.Errorf("failed to get collections: %w", err)
}
Expand All @@ -166,7 +161,6 @@ func (s *service) GetDatasetForInterval(ctx context.Context, collectionID uuid.U
SkipMeta: skipMeta,
},
))

if err != nil {
return nil, fmt.Errorf("failed to get dataset for interval: %w", err)
}
Expand All @@ -184,7 +178,6 @@ func (s *service) GetDatapointByID(ctx context.Context, collectionID uuid.UUID,
SkipData: skipData,
},
))

if err != nil {
return nil, fmt.Errorf("failed to get datapoint by id: %w", err)
}
Expand All @@ -204,7 +197,6 @@ func (s *service) IngestDatapoints(ctx context.Context, collectionID uuid.UUID,
AllowExisting: allowExisting,
},
))

if err != nil {
return nil, fmt.Errorf("failed to ingest datapoints: %w", err)
}
Expand All @@ -227,7 +219,6 @@ func (s *service) DeleteDatapoints(ctx context.Context, collectionID uuid.UUID,
}),
},
))

if err != nil {
return nil, fmt.Errorf("failed to delete datapoints: %w", err)
}
Expand Down
57 changes: 30 additions & 27 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ module github.com/tilebox/tilebox-go
go 1.23.1

require (
connectrpc.com/connect v1.17.0
connectrpc.com/connect v1.18.1
github.com/avast/retry-go/v4 v4.6.0
github.com/axiomhq/axiom-go v0.21.1
github.com/axiomhq/axiom-go v0.22.1
github.com/bufbuild/buf v1.47.2
github.com/google/uuid v1.6.0
github.com/hashicorp/go-retryablehttp v0.7.7
github.com/integrii/flaggy v1.5.2
github.com/remychantenay/slog-otel v1.3.2
github.com/samber/lo v1.47.0
github.com/samber/slog-multi v1.2.4
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/otel v1.32.0
go.opentelemetry.io/otel/sdk v1.32.0
go.opentelemetry.io/otel/trace v1.32.0
google.golang.org/grpc v1.68.0
google.golang.org/protobuf v1.35.2
github.com/stretchr/testify v1.10.0
go.opentelemetry.io/otel v1.34.0
go.opentelemetry.io/otel/sdk v1.34.0
go.opentelemetry.io/otel/trace v1.34.0
google.golang.org/grpc v1.69.4
google.golang.org/protobuf v1.36.3
pgregory.net/rapid v1.1.0
)

Expand Down Expand Up @@ -72,8 +72,8 @@ require (
github.com/google/cel-go v0.22.1 // indirect
github.com/google/go-containerregistry v0.20.2 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/pprof v0.0.0-20241122213907-cbe949e5a41b // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.24.0 // indirect
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jdx/go-netrc v1.0.0 // indirect
Expand All @@ -91,7 +91,7 @@ require (
github.com/moby/sys/userns v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/onsi/ginkgo/v2 v2.22.0 // indirect
github.com/onsi/ginkgo/v2 v2.22.2 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opencontainers/runtime-spec v1.2.0 // indirect
Expand All @@ -107,7 +107,7 @@ require (
github.com/segmentio/encoding v0.4.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
github.com/tetratelabs/wazero v1.8.2 // indirect
github.com/vbatts/tar-split v0.11.6 // indirect
Expand All @@ -116,26 +116,29 @@ require (
go.lsp.dev/protocol v0.12.0 // indirect
go.lsp.dev/uri v0.3.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.57.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.32.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.34.0 // indirect
go.opentelemetry.io/otel/metric v1.34.0 // indirect
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
go.uber.org/mock v0.5.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
go.uber.org/zap/exp v0.3.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/crypto v0.33.0 // indirect
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/tools v0.27.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241118233622-e639e219e697 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 // indirect
golang.org/x/mod v0.23.0 // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/term v0.29.0 // indirect
golang.org/x/text v0.22.0 // indirect
golang.org/x/time v0.8.0 // indirect
golang.org/x/tools v0.30.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
pluginrpc.com/pluginrpc v0.5.0 // indirect
)
Loading

0 comments on commit ac568b1

Please sign in to comment.