Skip to content

Commit

Permalink
RSDK-9290 - Bump go to 1.23 (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheukt authored Nov 19, 2024
1 parent 2682be8 commit 86ce518
Show file tree
Hide file tree
Showing 47 changed files with 1,109 additions and 1,791 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version-file: go.mod

- name: Setup node
uses: actions/setup-node@v3
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ buf-go: tool-install
lint: tool-install lint-go

lint-go: tool-install
go mod tidy
PATH=$(PATH_WITH_TOOLS) buf lint
export pkgs="`go list -f '{{.Dir}}' ./... | grep -v /proto/`" && echo "$$pkgs" | xargs go vet -vettool=$(TOOL_BIN)/combined
GOGC=50 $(TOOL_BIN)/golangci-lint run -v --fix --config=./etc/.golangci.yaml
Expand Down
72 changes: 50 additions & 22 deletions etc/.golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,57 +1,53 @@
service:
golangci-lint-version: 1.51.x
golangci-lint-version: 1.61.x
run:
timeout: 10m
deadline: 900s
modules-download-mode: readonly
skip-dirs:
- genfiles$
- gen$
- vendor$
- test$
skip-dirs-use-default: false
tests: true
linters:
enable-all: true
disable:
- asasalint
- canonicalheader
- containedctx
- contextcheck
- cyclop
- deadcode
- exhaustivestruct
- depguard
- exhaustruct
- forcetypeassert
- funlen
- gocognit
- godox
- goerr113
- err113
- gochecknoglobals
- gochecknoinits
- gocyclo
- gofmt
- goimports
- golint
- gomnd
- ifshort
- importas
- inamedparam
- interfacebloat
- interfacer
- intrange # TODO(go1.23): reenable in follow-up
- ireturn
- maintidx
- maligned
- makezero
- mnd
- musttag
- nakedret
- nestif
- nlreturn
- nosnakecase
- nonamedreturns
- nosprintfhostport
- paralleltest
- perfsprint
- prealloc
- scopelint
- structcheck
- spancheck # TODO(go1.23): reenable in follow-up
- tagliatelle
- testpackage
- thelper # false positives
- varcheck
- varnamelen
- wrapcheck
- wsl
Expand All @@ -64,24 +60,51 @@ linters-settings:
- default
- prefix(go.viam.com/utils)
gofumpt:
lang-version: "1.18"
lang-version: "1.23"
extra-rules: true
gosec:
excludes:
- G601
- G115 # TODO(go1.23): maybe reenable
govet:
enable-all: true
disable:
- fieldalignment
- shadow
- composites
lll:
line-length: 140
revive:
disable:
- package-comments
# Unfortunately disabling any single rules disables all other rules, even
# if we set `enable-all: true`
#
# To get around this, we include default rules:
# https://github.com/mgechev/revive/blob/master/defaults.toml
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: empty-block
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: exported
- name: increment-decrement
- name: indent-error-flow
- name: package-comments
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: time-naming
- name: unexported-return
# - name: unused-parameter # TODO(go1.23): maybe reenable
- name: unreachable-code
- name: var-declaration
- name: var-naming
issues:
exclude:
- composites
exclude-rules:
- path: _test\.go$|^tests/|^samples/
linters:
Expand All @@ -93,6 +116,11 @@ issues:
- gosec
- govet
- noctx
# statztest has the only set of exported methods that do not have a comment
- path: perf/statz/statztest/
linters:
- revive
text: exported
exclude-use-default: false
max-per-linter: 0
max-same-issues: 0
8 changes: 4 additions & 4 deletions flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func UnmarshalFlags(flagSet *flag.FlagSet, into interface{}) error {
}
fieldV := v.Field(i)
if info.IsFlagVal && !flagValIsSet {
if reflect.PtrTo(fieldV.Type()).Implements(flagValueT) {
if reflect.PointerTo(fieldV.Type()).Implements(flagValueT) {
fieldV = fieldV.Addr()
}
if err := fieldV.Interface().(flag.Value).Set(val.(string)); err != nil { // will always be string
Expand Down Expand Up @@ -242,7 +242,7 @@ func parseFlagInfo(field reflect.StructField, val string) (flagInfo, error) {
info.Position = int(posIdx)
info.Name = fmt.Sprintf("positional_arg_%d", posIdx)
}
if field.Type.Implements(flagValueT) || reflect.PtrTo(field.Type).Implements(flagValueT) {
if field.Type.Implements(flagValueT) || reflect.PointerTo(field.Type).Implements(flagValueT) {
info.IsFlagVal = true
}
for _, part := range valParts[1:] {
Expand Down Expand Up @@ -363,7 +363,7 @@ func extractFlags(flagSet *flag.FlagSet, from interface{}) error {
if flagValue.Kind() == reflect.Ptr {
flagValue = reflect.New(fieldT).Elem()
}
if reflect.PtrTo(fieldT).Implements(flagValueT) {
if reflect.PointerTo(fieldT).Implements(flagValueT) {
flagValue = flagValue.Addr()
}
flagSet.Var(&flagValueProxy{Value: flagValue.Interface().(flag.Value)}, info.Name, info.Usage)
Expand Down Expand Up @@ -393,7 +393,7 @@ func extractFlags(flagSet *flag.FlagSet, from interface{}) error {
case reflect.Slice:
sliceElem := fieldT.Elem()
var ctor func(val string) (interface{}, error)
if sliceElem.Implements(flagValueT) || reflect.PtrTo(sliceElem).Implements(flagValueT) {
if sliceElem.Implements(flagValueT) || reflect.PointerTo(sliceElem).Implements(flagValueT) {
ctor = func(val string) (interface{}, error) {
newSliceElem := reflect.New(sliceElem)
if err := newSliceElem.Interface().(flag.Value).Set(val); err != nil {
Expand Down
Loading

0 comments on commit 86ce518

Please sign in to comment.