Skip to content

Commit 3595235

Browse files
authored
upgrade go version to 1.24.1 (#15)
1 parent 32f4e70 commit 3595235

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+259
-262
lines changed

.github/workflows/code-health.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
go-version-file: 'go.mod'
1818
cache: false # see https://github.com/golangci/golangci-lint-action/issues/807
1919
- name: golangci-lint
20-
uses: golangci/[email protected].0
20+
uses: golangci/[email protected].2
2121
with:
22-
version: v1.56.1
22+
version: v1.64.6
2323
unit-tests:
2424
env:
2525
COVERAGE: coverage.out

.golangci.yml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ linters-settings:
66
min-occurrences: 2
77
gocyclo:
88
min-complexity: 15
9-
govet:
10-
check-shadowing: true
11-
maligned:
12-
suggest-new: true
139
misspell:
1410
locale: US
1511
ignore-words:
@@ -23,12 +19,15 @@ linters-settings:
2319
- name: blank-imports
2420
- name: context-as-argument
2521
- name: context-keys-type
22+
- name: defer
2623
- name: dot-imports
2724
- name: error-return
2825
- name: error-strings
2926
- name: error-naming
27+
- name: early-return
3028
- name: errorf
3129
- name: exported
30+
- name: import-shadowing
3231
- name: indent-error-flow
3332
- name: if-return
3433
- name: increment-decrement
@@ -52,23 +51,22 @@ linters-settings:
5251
- name: constant-logical-expr
5352
- name: confusing-naming
5453
- name: unnecessary-stmt
55-
- name: imports-blacklist
54+
- name: use-any
55+
- name: imports-blocklist
5656
arguments:
5757
- "github.com/pkg/errors"
5858
gci:
5959
sections:
6060
- standard
6161
- default
62-
section-separators:
63-
- newLine
6462
linters:
6563
disable-all: true
6664
enable:
6765
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) [fast: true, auto-fix: false]
6866
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: false, auto-fix: false]
6967
- errorlint # Errorlint is a linter that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
7068
- exhaustive # check exhaustiveness of enum switch statements [fast: false, auto-fix: false]
71-
- exportloopref # checks for pointers to enclosing loop variables [fast: false, auto-fix: false]
69+
- copyloopvar # copyloopvar is a linter detects places where loop variables are copied. Replaces exportloopref since Go1.22
7270
- gci # Gci controls golang package import order and makes it always deterministic. [fast: true, auto-fix: false]
7371
- gochecknoinits # Checks that no init functions are present in Go code [fast: true, auto-fix: false]
7472
- goconst # Finds repeated strings that could be replaced by a constant [fast: true, auto-fix: false]
@@ -77,7 +75,7 @@ linters:
7775
- godot # Check if comments end in a period [fast: true, auto-fix: true]
7876
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true]
7977
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt. [fast: true, auto-fix: true]
80-
- gomnd # An analyzer to detect magic numbers. [fast: true, auto-fix: false]
78+
- mnd # An analyzer to detect magic numbers. [fast: true, auto-fix: false]
8179
- goprintffuncname # Checks that printf-like functions are named with `f` at the end [fast: true, auto-fix: false]
8280
- gosec # (gas) Inspects source code for security problems [fast: false, auto-fix: false]
8381
- gosimple # (megacheck) Linter for Go source code that specializes in simplifying code [fast: false, auto-fix: false]
@@ -94,7 +92,7 @@ linters:
9492
- rowserrcheck # checks whether Err of rows is checked successfully [fast: false, auto-fix: false]
9593
- staticcheck # (megacheck) It's a set of rules from staticcheck. It's not the same thing as the staticcheck binary. The author of staticcheck doesn't support or approve the use of staticcheck as a library inside golangci-lint. [fast: false, auto-fix: false]
9694
- stylecheck # Stylecheck is a replacement for golint [fast: false, auto-fix: false]
97-
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 [fast: false, auto-fix: false]
95+
- usetesting # Reports uses of functions with replacement inside the testing package. [auto-fix]
9896
- testifylint # Checks usage of github.com/stretchr/testify. [fast: false, auto-fix: false]
9997
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers [fast: false, auto-fix: false]
10098
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code [fast: false, auto-fix: false]
@@ -174,8 +172,6 @@ run:
174172
- e2e
175173
- unit
176174
- integration
177-
skip-dirs:
178-
- internal/mocks
179175
modules-download-mode: readonly
180176

181177
issues:
@@ -186,9 +182,4 @@ issues:
186182
- gocyclo
187183
- path: internal/test/fixture # Don't check for magic numbers on fixtures.
188184
linters:
189-
- gomnd
190-
- path: internal/kubernetes/*
191-
linters:
192-
- nolintlint
193-
- gci
194-
- gocyclo
185+
- mnd

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/mongodb/mongodb-cli/mongocli/v2
22

3-
go 1.22.5
3+
go 1.24.1
44

55
require (
66
github.com/AlecAivazis/survey/v2 v2.3.7

internal/cli/auth/login_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package auth
1818

1919
import (
2020
"bytes"
21-
"context"
2221
"errors"
2322
"fmt"
2423
"testing"
@@ -76,7 +75,7 @@ func Test_loginOpts_Run(t *testing.T) {
7675
ExpiresIn: 300,
7776
Interval: 10,
7877
}
79-
ctx := context.TODO()
78+
ctx := t.Context()
8079
mockFlow.
8180
EXPECT().
8281
RequestCode(ctx).
@@ -129,11 +128,11 @@ Successfully logged in as [email protected].
129128

130129
type confirmMock struct{}
131130

132-
func (confirmMock) Prompt(_ *survey.PromptConfig) (interface{}, error) {
131+
func (confirmMock) Prompt(_ *survey.PromptConfig) (any, error) {
133132
return true, nil
134133
}
135134

136-
func (confirmMock) Cleanup(_ *survey.PromptConfig, _ interface{}) error {
135+
func (confirmMock) Cleanup(_ *survey.PromptConfig, _ any) error {
137136
return nil
138137
}
139138

internal/cli/auth/logout_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package auth
1818

1919
import (
2020
"bytes"
21-
"context"
2221
"testing"
2322

2423
"github.com/golang/mock/gomock"
@@ -53,7 +52,7 @@ func Test_logoutOpts_Run(t *testing.T) {
5352
Confirm: true,
5453
},
5554
}
56-
ctx := context.TODO()
55+
ctx := t.Context()
5756
mockFlow.
5857
EXPECT().
5958
RevokeToken(ctx, gomock.Any(), gomock.Any()).
@@ -83,7 +82,7 @@ func Test_logoutOpts_Run_Keep(t *testing.T) {
8382
},
8483
keepConfig: true,
8584
}
86-
ctx := context.TODO()
85+
ctx := t.Context()
8786
mockFlow.
8887
EXPECT().
8988
RevokeToken(ctx, gomock.Any(), gomock.Any()).

internal/cli/config/set.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (opts *SetOpts) Run() error {
4343
return err
4444
}
4545
}
46-
var value interface{}
46+
var value any
4747
value = opts.val
4848
if search.StringInSlice(config.BooleanProperties(), opts.prop) {
4949
value = config.IsTrue(opts.val)

internal/cli/delete_opts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func NewDeleteOpts(successMsg, failMsg string) *DeleteOpts {
4646

4747
// Delete deletes a resource not associated to a project, it expects a callback
4848
// that should perform the deletion from the store.
49-
func (opts *DeleteOpts) Delete(d interface{}, a ...string) error {
49+
func (opts *DeleteOpts) Delete(d any, a ...string) error {
5050
if !opts.Confirm {
5151
fmt.Println(opts.FailMessage())
5252
return nil

internal/cli/iam/projects/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (opts *ListOpts) initStore(ctx context.Context) func() error {
4848
}
4949

5050
func (opts *ListOpts) Run() error {
51-
var r interface{}
51+
var r any
5252
var err error
5353
listOptions := opts.NewListOptions()
5454
if opts.ConfigOrgID() != "" && config.Service() == config.OpsManagerService {

internal/cli/iam/teams/describe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (opts *DescribeOpts) initStore(ctx context.Context) func() error {
4949
}
5050

5151
func (opts *DescribeOpts) Run() error {
52-
var r interface{}
52+
var r any
5353
var err error
5454

5555
if opts.name != "" {

internal/cli/iam/users/describe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (opts *DescribeOpts) initStore(ctx context.Context) func() error {
4848
}
4949

5050
func (opts *DescribeOpts) Run() error {
51-
var r interface{}
51+
var r any
5252
var err error
5353

5454
if opts.username != "" {

0 commit comments

Comments
 (0)