Skip to content

Commit 60e2eb1

Browse files
authored
Merge branch 'master' into merge-release/2.4-into-master-1764991952948
2 parents c3077a1 + d17ef8b commit 60e2eb1

File tree

109 files changed

+398
-444
lines changed

Some content is hidden

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

109 files changed

+398
-444
lines changed

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
steps:
3636
- name: Checkout repository
37-
uses: actions/checkout@v5
37+
uses: actions/checkout@v6
3838

3939
# Initializes the CodeQL tools for scanning.
4040
- name: Initialize CodeQL

.github/workflows/scorecard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
steps:
3636
- name: "Checkout code"
37-
uses: actions/checkout@v5
37+
uses: actions/checkout@v6
3838
with:
3939
persist-credentials: false
4040

@@ -64,7 +64,7 @@ jobs:
6464
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
6565
# format to the repository Actions tab.
6666
- name: "Upload artifact"
67-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
67+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
6868
with:
6969
name: SARIF file
7070
path: results.sarif

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
pre_commit:
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v5
19+
- uses: actions/checkout@v6
2020
- uses: actions/setup-python@v6
2121
- uses: actions/setup-go@v6
2222
with:

.golangci.yml

Lines changed: 125 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
run:
2-
timeout: 5m
3-
1+
version: "2"
42
linters:
5-
disable-all: true
6-
# TODO(GODRIVER-2156): Enable all commented-out linters.
3+
default: none
74
enable:
85
- errcheck
9-
# - errorlint
10-
- exportloopref
116
- gocritic
12-
- goimports
13-
- gosimple
14-
- gosec
7+
# TODO(GODRIVER-3712): Enable gosec in golangci-lint version 2.6.2
8+
#- gosec
159
- govet
1610
- ineffassign
1711
- makezero
@@ -21,95 +15,129 @@ linters:
2115
- prealloc
2216
- revive
2317
- staticcheck
24-
- typecheck
25-
- unused
2618
- unconvert
2719
- unparam
20+
- unused
21+
settings:
22+
errcheck:
23+
exclude-functions:
24+
- .errcheck-excludes
25+
govet:
26+
disable:
27+
- cgocall
28+
- composites
29+
paralleltest:
30+
# Ignore missing calls to `t.Parallel()` and only report incorrect uses of
31+
# `t.Parallel()`.
32+
ignore-missing: true
33+
staticcheck:
34+
checks:
35+
- all
36+
# Disable deprecation warnings for now.
37+
- -SA1012
38+
# Disable "do not pass a nil Context" to allow testing nil contexts in
39+
# tests.
40+
- -SA1019
41+
exclusions:
42+
generated: lax
43+
rules:
44+
# Ignore some linters for example code that is intentionally simplified.
45+
- linters:
46+
- errcheck
47+
- revive
48+
path: examples/
49+
# Disable "unused" linter for code files that depend on the
50+
# "mongocrypt.MongoCrypt" type because the linter build doesn't work
51+
# correctly with CGO enabled. As a result, all calls to a
52+
# "mongocrypt.MongoCrypt" API appear to always panic (see
53+
# mongocrypt_not_enabled.go), leading to confusing messages about unused
54+
# code.
55+
- linters:
56+
- unused
57+
path: x/mongo/driver/crypt.go|mongo/(crypt_retrievers|mongocryptd).go
58+
# Ignore "TLS MinVersion too low", "TLS InsecureSkipVerify set true", and
59+
# "Use of weak random number generator (math/rand instead of crypto/rand)"
60+
# in tests. Disable gosec entirely for test files to reduce noise.
61+
- linters:
62+
- gosec
63+
path: _test\.go
64+
# Ignore missing comments for exported variable/function/type for code in
65+
# the "internal" and "benchmark" directories.
66+
- path: (internal\/|benchmark\/)
67+
text: exported (.+) should have comment( \(or a comment on this block\))? or be unexported
68+
# Ignore missing package comments for directories that aren't frequently
69+
# used by external users.
70+
- path: (internal\/|benchmark\/|x\/|cmd\/|mongo\/integration\/)
71+
text: should have a package comment
2872

29-
linters-settings:
30-
errcheck:
31-
exclude-functions: .errcheck-excludes
32-
govet:
33-
disable:
34-
- cgocall
35-
- composites
36-
paralleltest:
37-
# Ignore missing calls to `t.Parallel()` and only report incorrect uses of `t.Parallel()`.
38-
ignore-missing: true
39-
staticcheck:
40-
checks: [
41-
"all",
42-
"-SA1019", # Disable deprecation warnings for now.
43-
"-SA1012", # Disable "do not pass a nil Context" to allow testing nil contexts in tests.
44-
]
45-
46-
issues:
47-
exclude-dirs-use-default: false
48-
exclude-dirs:
49-
- (^|/)testdata($|/)
50-
- (^|/)etc($|/)
51-
# Disable all linters for copied third-party code.
52-
- internal/rand
53-
- internal/aws
54-
- internal/assert
55-
exclude-use-default: false
56-
exclude:
57-
# Add all default excluded issues except issues related to exported types/functions not having
58-
# comments; we want those warnings. The defaults are copied from the "--exclude-use-default"
59-
# documentation on https://golangci-lint.run/usage/configuration/#command-line-options
60-
## Defaults ##
61-
# EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
62-
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
63-
# EXC0003 golint: False positive when tests are defined in package 'test'
64-
- func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
65-
# EXC0004 govet: Common false positives
66-
- (possible misuse of unsafe.Pointer|should have signature)
67-
# EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
68-
- ineffective break statement. Did you mean to break out of the outer loop
69-
# EXC0006 gosec: Too many false-positives on 'unsafe' usage
70-
- Use of unsafe calls should be audited
71-
# EXC0007 gosec: Too many false-positives for parametrized shell calls
72-
- Subprocess launch(ed with variable|ing should be audited)
73-
# EXC0008 gosec: Duplicated errcheck checks
74-
- (G104|G307)
75-
# EXC0009 gosec: Too many issues in popular repos
76-
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
77-
# EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
78-
- Potential file inclusion via variable
79-
## End Defaults ##
73+
# Add all default excluded issues except issues related to exported
74+
# types/functions not having comments; we want those warnings. The
75+
# defaults are copied from the "--exclude-use-default" documentation on
76+
# https://golangci-lint.run/usage/configuration/#command-line-options
77+
#
78+
## Defaults ##
79+
#
80+
# EXC0001 errcheck: Almost all programs ignore errors on these functions
81+
# and in most cases it's ok
82+
- path: (.+)\.go$
83+
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
84+
# EXC0003 golint: False positive when tests are defined in package 'test'
85+
- path: (.+)\.go$
86+
text: func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
87+
# EXC0004 govet: Common false positives
88+
- path: (.+)\.go$
89+
text: (possible misuse of unsafe.Pointer|should have signature)
90+
# EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
91+
- path: (.+)\.go$
92+
text: ineffective break statement. Did you mean to break out of the outer loop
93+
# EXC0006 gosec: Too many false-positives on 'unsafe' usage
94+
- path: (.+)\.go$
95+
text: Use of unsafe calls should be audited
96+
# EXC0007 gosec: Too many false-positives for parametrized shell calls
97+
- path: (.+)\.go$
98+
text: Subprocess launch(ed with variable|ing should be audited)
99+
# EXC0008 gosec: Duplicated errcheck checks
100+
- path: (.+)\.go$
101+
text: (G104|G307)
102+
# EXC0009 gosec: Too many issues in popular repos
103+
- path: (.+)\.go$
104+
text: (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
105+
# EXC0010 gosec: False positive is triggered by
106+
# 'src, err := ioutil.ReadFile(filename)'
107+
- path: (.+)\.go$
108+
text: Potential file inclusion via variable
109+
## End Defaults ##
80110

81-
# Ignore capitalization warning for this weird field name.
82-
- "var-naming: struct field CqCssWxW should be CqCSSWxW"
83-
# Ignore warnings for common "wiremessage.Read..." usage because the safest way to use that API
84-
# is by assigning possibly unused returned byte buffers.
85-
- "SA4006: this value of `wm` is never used"
86-
- "SA4006: this value of `rem` is never used"
87-
- "ineffectual assignment to wm"
88-
- "ineffectual assignment to rem"
111+
# Ignore capitalization warning for this weird field name.
112+
- path: (.+)\.go$
113+
text: "var-naming: struct field CqCssWxW should be CqCSSWxW"
89114

90-
exclude-rules:
91-
# Ignore some linters for example code that is intentionally simplified.
92-
- path: examples/
93-
linters:
94-
- revive
95-
- errcheck
96-
# Disable "unused" linter for code files that depend on the "mongocrypt.MongoCrypt" type because
97-
# the linter build doesn't work correctly with CGO enabled. As a result, all calls to a
98-
# "mongocrypt.MongoCrypt" API appear to always panic (see mongocrypt_not_enabled.go), leading
99-
# to confusing messages about unused code.
100-
- path: x/mongo/driver/crypt.go|mongo/(crypt_retrievers|mongocryptd).go
101-
linters:
102-
- unused
103-
# Ignore "TLS MinVersion too low", "TLS InsecureSkipVerify set true", and "Use of weak random
104-
# number generator (math/rand instead of crypto/rand)" in tests.
105-
- path: _test\.go
106-
text: G401|G402|G404
107-
linters:
108-
- gosec
109-
# Ignore missing comments for exported variable/function/type for code in the "internal" and
110-
# "benchmark" directories.
111-
- path: (internal\/|benchmark\/)
112-
text: exported (.+) should have comment( \(or a comment on this block\))? or be unexported
113-
# Ignore missing package comments for directories that aren't frequently used by external users.
114-
- path: (internal\/|benchmark\/|x\/|cmd\/|mongo\/integration\/)
115-
text: should have a package comment
115+
# Ignore warnings for common "wiremessage.Read..." usage because the
116+
# safest way to use that API is by assigning possibly unused returned byte
117+
# buffers.
118+
- path: (.+)\.go$
119+
text: "SA4006: this value of `wm` is never used"
120+
- path: (.+)\.go$
121+
text: "SA4006: this value of `rem` is never used"
122+
- path: (.+)\.go$
123+
text: ineffectual assignment to wm
124+
- path: (.+)\.go$
125+
text: ineffectual assignment to rem
126+
paths:
127+
- (^|/)testdata($|/)
128+
- (^|/)etc($|/)
129+
# Disable all linters for copied third-party code.
130+
- internal/rand
131+
- internal/aws
132+
- internal/assert
133+
formatters:
134+
enable:
135+
- goimports
136+
exclusions:
137+
generated: lax
138+
paths:
139+
- (^|/)testdata($|/)
140+
- (^|/)etc($|/)
141+
- internal/rand
142+
- internal/aws
143+
- internal/assert

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The MongoDB Go driver follows [semantic versioning](https://semver.org/) for its
2323
## Requirements
2424

2525
- Go 1.19 or higher. We aim to support the latest versions of Go.
26-
- Go 1.23 or higher is required to run the driver test suite.
26+
- Go 1.25 or higher is required to run the driver test suite.
2727
- MongoDB 4.2 and higher.
2828

2929
## Installation

THIRD-PARTY-NOTICES

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -327,38 +327,6 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
327327
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
328328
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
329329

330-
----------------------------------------------------------------------
331-
License notice for github.com/golang/snappy
332-
----------------------------------------------------------------------
333-
334-
Copyright (c) 2011 The Snappy-Go Authors. All rights reserved.
335-
336-
Redistribution and use in source and binary forms, with or without
337-
modification, are permitted provided that the following conditions are
338-
met:
339-
340-
* Redistributions of source code must retain the above copyright
341-
notice, this list of conditions and the following disclaimer.
342-
* Redistributions in binary form must reproduce the above
343-
copyright notice, this list of conditions and the following disclaimer
344-
in the documentation and/or other materials provided with the
345-
distribution.
346-
* Neither the name of Google Inc. nor the names of its
347-
contributors may be used to endorse or promote products derived from
348-
this software without specific prior written permission.
349-
350-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
351-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
352-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
353-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
354-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
355-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
356-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
357-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
358-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
359-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
360-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
361-
362330
----------------------------------------------------------------------
363331
License notice for github.com/google/go-cmp
364332
----------------------------------------------------------------------

bson/map_codec.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ func (mc *mapCodec) EncodeValue(ec EncodeContext, vw ValueWriter, val reflect.Va
7979
// true if the provided key exists, this is mainly used for inline maps in the
8080
// struct codec.
8181
func (mc *mapCodec) encodeMapElements(ec EncodeContext, dw DocumentWriter, val reflect.Value, collisionFn func(string) bool) error {
82-
8382
elemType := val.Type().Elem()
8483
encoder, err := ec.LookupEncoder(elemType)
8584
if err != nil && elemType.Kind() != reflect.Interface {
@@ -237,8 +236,10 @@ func (mc *mapCodec) encodeKey(val reflect.Value, encodeKeysWithStringer bool) (s
237236
return "", fmt.Errorf("unsupported key type: %v", val.Type())
238237
}
239238

240-
var keyUnmarshalerType = reflect.TypeOf((*KeyUnmarshaler)(nil)).Elem()
241-
var textUnmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem()
239+
var (
240+
keyUnmarshalerType = reflect.TypeOf((*KeyUnmarshaler)(nil)).Elem()
241+
textUnmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem()
242+
)
242243

243244
func (mc *mapCodec) decodeKey(key string, keyType reflect.Type) (reflect.Value, error) {
244245
keyVal := reflect.ValueOf(key)
@@ -278,7 +279,7 @@ func (mc *mapCodec) decodeKey(key string, keyType reflect.Type) (reflect.Value,
278279
if mc.encodeKeysWithStringer {
279280
parsed, err := strconv.ParseFloat(key, 64)
280281
if err != nil {
281-
return keyVal, fmt.Errorf("Map key is defined to be a decimal type (%v) but got error %w", keyType.Kind(), err)
282+
return keyVal, fmt.Errorf("map key is defined to be a decimal type (%v) but got error %w", keyType.Kind(), err)
282283
}
283284
keyVal = reflect.ValueOf(parsed)
284285
break

bson/mgoregistry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func getterEncodeValue(ec EncodeContext, vw ValueWriter, val reflect.Value) erro
201201
return vw.WriteNull()
202202
}
203203
vv := reflect.ValueOf(x)
204-
encoder, err := ec.Registry.LookupEncoder(vv.Type())
204+
encoder, err := ec.LookupEncoder(vv.Type())
205205
if err != nil {
206206
return err
207207
}

docs/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ We are building this software together and strongly encourage contributions from
66

77
## Requirements
88

9-
Go 1.23 or higher is required to run the driver test suite. We use [task](https://taskfile.dev/) as our task runner.
9+
Go 1.25 or higher is required to run the driver test suite. We use [task](https://taskfile.dev/) as our task runner.
1010

1111
## Bug Fixes and New Features
1212

@@ -18,7 +18,7 @@ The Go Driver team uses GitHub to manage and review all code changes. Pull reque
1818

1919
When creating a pull request, please ensure that your code adheres to the following guidelines:
2020

21-
Code should compile and tests should pass under all Go versions which the driver currently supports. Currently, the Go Driver supports a minimum version of Go 1.19 and requires Go 1.23 for development. Please run the following `Taskfile` targets to validate your changes:
21+
Code should compile and tests should pass under all Go versions which the driver currently supports. Currently, the Go Driver supports a minimum version of Go 1.19 and requires Go 1.25 for development. Please run the following `Taskfile` targets to validate your changes:
2222

2323
- `task fmt`
2424
- `task lint`

etc/golangci-lint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
set -ex
33

44
# Keep this in sync with go version used in static-analysis Evergreen build variant.
5-
GO_VERSION=1.23.0
6-
GOLANGCI_LINT_VERSION=1.60.1
5+
GO_VERSION=1.25.0
6+
GOLANGCI_LINT_VERSION=2.6.2
77

88
# Unset the cross-compiler overrides while downloading binaries.
99
GOOS_ORIG=${GOOS:-}

0 commit comments

Comments
 (0)