Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK-9290 - Bump go to 1.23 #392

Merged
merged 6 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the changes to disabled linters are mirrored from rdk

- 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
Loading