Skip to content

Commit

Permalink
Go 1.23
Browse files Browse the repository at this point in the history
Use go 1.23 toolchain
Fix new linter errors.

Fixes AB#9842
  • Loading branch information
eccles committed Aug 30, 2024
1 parent b53133f commit 822e11b
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .env.tools
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export TOOLS_BUILDNUMBER=20240805.1
export TOOLS_BUILDNUMBER=20240829.1
60 changes: 35 additions & 25 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,26 @@ linters-settings:
# Default: false
explicit-exhaustive-map: false
gci:
local-prefixes: jitsuin.com/avid
# Section configuration to compare against.
# Section names are case-insensitive and may contain parameters in ().
# The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`,
# If `custom-order` is `true`, it follows the order of `sections` option.
# Default: ["standard", "default"]
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/datatrails/avid) # Custom section: groups all imports with the specified Prefix.
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
- alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled.
- localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled.
# Skip generated files.
# Default: true
skip-generated: false
# Enable custom order of sections.
# If `true`, make the section order the same as the order of `sections`.
# Default: false
custom-order: true
goconst:
min-len: 2
min-occurrences: 2
Expand All @@ -72,16 +91,13 @@ linters-settings:
min-complexity: 10
goimports:
local-prefixes: github.com/golangci/golangci-lint
golint:
min-confidence: 0
govet:
check-shadowing: true
settings:
printf:
funcs:
- Infof
- Warnf
- Errorf
- Debugf
- Panicf
- Fatalf
lll:
line-length: 500
Expand All @@ -108,7 +124,7 @@ linters-settings:
# paths anyway (we have no control over there layout). Until we get
# direct evidence this is hurting us, we prefer our stucts layed out
# logically and don't want to have to nolint tag everything.
#
#
# misspell - expected UK spelling with misspell, but customer facing text needs to be US.
# tagalign - suppress until we can get a golang code formatter that will fix this (cosmetic)
#
Expand All @@ -118,18 +134,20 @@ linters-settings:
linters:
enable-all: true
disable:
- canonicalheader
- containedctx
- contextcheck
- cyclop
- deadcode
- depguard
- dupl
- dupword
- durationcheck
- err113
- errchkjson
- errname
- exhaustivestruct
- execinquery
- exhaustruct
- exportloopref
- forbidigo
- forcetypeassert
# DONT re-enable funlen please
Expand All @@ -141,21 +159,17 @@ linters:
- gocyclo
- godot
- godox
- goerr113
- gofumpt
- golint
- gomoddirectives
- gomnd
- gosec
- gosimple
- ifshort
- inamedparam
- interfacer
- interfacebloat
- ireturn
- maligned
- maintidx
- misspell
- mnd
- musttag
- nilerr
- nilnil
Expand All @@ -164,16 +178,13 @@ linters:
- nestif
- nolintlint
- nonamedreturns
- nosnakecase
- nosprintfhostport
- paralleltest
- perfsprint
- protogetter
- prealloc
- protogetter
- revive
- rowserrcheck
- scopelint
- structcheck
- stylecheck
- tagalign
- tagliatelle
Expand All @@ -185,24 +196,23 @@ linters:
- unparam
- unused
- usestdlibvars
- varcheck
- varnamelen
- wastedassign
- whitespace
- wsl
- wrapcheck

run:
skip-dirs:
- api
- azb2c
skip-files:
- service/b2cpoliciesv1/b2cpolicies.go
- service/tenanciesv1/users_store.go
build-tags:
- golangcilint

issues:
exclude-dirs:
- api
- azb2c
exclude-files:
- service/b2cpoliciesv1/b2cpolicies.go
- service/tenanciesv1/users_store.go
exclude-rules:
- text: "weak cryptographic primitive"
linters:
Expand Down
2 changes: 1 addition & 1 deletion azblob/storer.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func New(

if container == "" {
msg := "storer: container is unspecified"
logger.Sugar.Infof(msg)
logger.Sugar.Infof(msg) //nolint:govet
return nil, errors.New(msg)
}
azp := &Storer{
Expand Down
29 changes: 17 additions & 12 deletions azbus/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,20 +240,25 @@ func (r *Receiver) receiveMessages(ctx context.Context) error {
select {
case <-rctx.Done():
rr.log.Debugf("Stop worker %d", ii)
wg.Done()
return
case msg := <-msgs:
var renewCtx context.Context
var renewCancel context.CancelFunc
var maxDuration time.Duration
if rr.Cfg.RenewMessageLock {
renewCtx, renewCancel = context.WithCancel(rctx)
go rr.renewMessageLock(renewCtx, ii+1, msg)
} else {
// we need a timeout if RenewMessageLock is disabled
renewCtx, renewCancel, maxDuration = rr.setTimeout(rctx, rr.log, msg)
}
rr.processMessage(renewCtx, ii+1, maxDuration, msg, rr.handlers[ii])
renewCancel()
rr.log.Infof("XXXXXStart worker %d", ii)
func(rrctx context.Context) {
var renewCtx context.Context
var renewCancel context.CancelFunc
var maxDuration time.Duration
if rr.Cfg.RenewMessageLock {
renewCtx, renewCancel = context.WithCancel(rrctx)
go rr.renewMessageLock(renewCtx, ii+1, msg)
defer renewCancel()
} else {
// we need a timeout if RenewMessageLock is disabled
renewCtx, renewCancel, maxDuration = rr.setTimeout(rrctx, rr.log, msg)
defer renewCancel()
}
rr.processMessage(renewCtx, ii+1, maxDuration, msg, rr.handlers[ii])
}(rctx)
wg.Done()
}
}
Expand Down
2 changes: 1 addition & 1 deletion httpserver/httpserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func WithHandlers(handlers ...HandleChainFunc) ServerOption {
// it is ignored.
func WithOptionalHandlers(handlers ...HandleChainFunc) ServerOption {
return func(s *Server) {
for i := 0; i < len(handlers); i++ {
for i := range len(handlers) {
handler := handlers[i]
if handler != nil && !reflect.ValueOf(handler).IsNil() {
s.handlers = append(s.handlers, handler)
Expand Down
2 changes: 1 addition & 1 deletion redis/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func FromEnvOrFatal(log Logger) RedisConfig {
cfg.clusterOptions.PoolSize = nodePoolSize
cfg.clusterOptions.Addrs = make([]string, 0, cfg.Size)
cfg.clusterOptions.MaxRedirects = cfg.Size
for i := 0; i < cfg.Size; i++ {
for i := range cfg.Size {
suffix := fmt.Sprintf(RedisNodeAddressFmtSuffix, i)
cfg.clusterOptions.Addrs = append(
cfg.clusterOptions.Addrs,
Expand Down
4 changes: 2 additions & 2 deletions restproxyserver/restproxyserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func WithRegisterHandlers(registerers ...RegisterRESTProxyServer) RESTProxyServe
// ignored.
func WithOptionalRegisterHandlers(registerers ...RegisterRESTProxyServer) RESTProxyServerOption {
return func(g *RESTProxyServer) {
for i := 0; i < len(registerers); i++ {
for i := range len(registerers) {
registerer := registerers[i]
if registerer != nil && !reflect.ValueOf(registerer).IsNil() {
g.registers = append(g.registers, registerer)
Expand All @@ -141,7 +141,7 @@ func WithHTTPHandlers(handlers ...HandleChainFunc) RESTProxyServerOption {
// be ignored.
func WithOptionalHTTPHandlers(handlers ...HandleChainFunc) RESTProxyServerOption {
return func(g *RESTProxyServer) {
for i := 0; i < len(handlers); i++ {
for i := range len(handlers) {
handler := handlers[i]
if handler != nil && !reflect.ValueOf(handler).IsNil() {
g.handlers = append(g.handlers, handler)
Expand Down

0 comments on commit 822e11b

Please sign in to comment.