Skip to content

Commit 58b5da8

Browse files
author
Divjot Arora
committed
Use Go 1.15 in Evergreen
This commit also fixes errors from "go vet" and "gofmt". GODRIVER-1729 GODRIVER-1730
1 parent 4fdf115 commit 58b5da8

File tree

6 files changed

+49
-31
lines changed

6 files changed

+49
-31
lines changed

.evergreen/config.yml

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,14 @@ functions:
134134
working_dir: src/go.mongodb.org/mongo-driver
135135
script: |
136136
${PREPARE_SHELL}
137-
# any go tools that we need
137+
138+
# Install any go tools that we need. Do this in a temp directory because running "go get" inside the driver
139+
# repo will update the driver's go.mod/go.sum files. This puts the contents of go.mod/go.sum out of sync with
140+
# the vendor directory and tests fail to compile due to inconsistent vendoring.
141+
cd $(mktemp -d)
138142
go get -u golang.org/x/lint/golint
139143
go get -u github.com/kisielk/errcheck
144+
cd -
140145
141146
# initialize submodules
142147
git submodule init
@@ -1562,61 +1567,61 @@ axes:
15621567
- id: os-ssl-legacy
15631568
display_name: OS
15641569
values:
1565-
- id: "ubuntu1404-go-1-13"
1570+
- id: "ubuntu1404-go-1-15"
15661571
display_name: "Ubuntu 14.04"
15671572
run_on: ubuntu1404-test
15681573
variables:
1569-
GO_DIST: "/opt/golang/go1.13"
1574+
GO_DIST: "/opt/golang/go1.15"
15701575

15711576
# OSes that require >= 3.2 for SSL
15721577
- id: os-ssl-32
15731578
display_name: OS
15741579
values:
1575-
- id: "windows-64-go-1-13"
1580+
- id: "windows-64-go-1-15"
15761581
display_name: "Windows 64-bit"
15771582
run_on:
15781583
- windows-64-vs2017-test
15791584
variables:
15801585
GCC_PATH: "/cygdrive/c/mingw-w64/x86_64-4.9.1-posix-seh-rt_v3-rev1/mingw64/bin"
1581-
GO_DIST: "C:\\golang\\go1.13"
1586+
GO_DIST: "C:\\golang\\go1.15"
15821587
PYTHON3_BINARY: "C:/python/Python38/python.exe"
15831588
VENV_BIN_DIR: "Scripts"
1584-
- id: "ubuntu1604-64-go-1-13"
1589+
- id: "ubuntu1604-64-go-1-15"
15851590
display_name: "Ubuntu 16.04"
15861591
run_on: ubuntu1604-build
15871592
variables:
1588-
GO_DIST: "/opt/golang/go1.13"
1593+
GO_DIST: "/opt/golang/go1.15"
15891594
PYTHON3_BINARY: "/opt/python/3.8/bin/python3"
1590-
- id: "osx-go-1-13"
1595+
- id: "osx-go-1-15"
15911596
display_name: "MacOS 10.14"
15921597
run_on: macos-1014
15931598
variables:
1594-
GO_DIST: "/opt/golang/go1.13"
1599+
GO_DIST: "/opt/golang/go1.15"
15951600
PYTHON3_BINARY: python3
15961601

15971602
- id: os-aws-auth
15981603
display_name: OS
15991604
values:
1600-
- id: "windows-64-vsMulti-small-go-1-13"
1605+
- id: "windows-64-vsMulti-small-go-1-15"
16011606
display_name: "Windows 64-bit"
16021607
run_on:
16031608
- windows-64-vsMulti-small
16041609
variables:
16051610
GCC_PATH: "/cygdrive/c/mingw-w64/x86_64-4.9.1-posix-seh-rt_v3-rev1/mingw64/bin"
1606-
GO_DIST: "C:\\golang\\go1.13"
1611+
GO_DIST: "C:\\golang\\go1.15"
16071612
SKIP_ECS_AUTH_TEST: true
16081613
PYTHON3: "C:/python/Python38/python.exe"
1609-
- id: "ubuntu1804-64-go-1-13"
1614+
- id: "ubuntu1804-64-go-1-15"
16101615
display_name: "Ubuntu 18.04"
16111616
run_on: ubuntu1804-test
16121617
variables:
1613-
GO_DIST: "/opt/golang/go1.13"
1618+
GO_DIST: "/opt/golang/go1.15"
16141619
PYTHON3: python3
1615-
- id: "osx-go-1-13"
1620+
- id: "osx-go-1-15"
16161621
display_name: "MacOS 10.14"
16171622
run_on: macos-1014
16181623
variables:
1619-
GO_DIST: "/opt/golang/go1.13"
1624+
GO_DIST: "/opt/golang/go1.15"
16201625
SKIP_ECS_AUTH_TEST: true
16211626
SKIP_EC2_AUTH_TEST: true
16221627
PYTHON3: python3
@@ -1627,7 +1632,7 @@ buildvariants:
16271632
run_on:
16281633
- ubuntu1604-build
16291634
expansions:
1630-
GO_DIST: "/opt/golang/go1.13"
1635+
GO_DIST: "/opt/golang/go1.15"
16311636
tasks:
16321637
- name: ".static-analysis"
16331638

@@ -1636,7 +1641,7 @@ buildvariants:
16361641
run_on:
16371642
- ubuntu1604-build
16381643
expansions:
1639-
GO_DIST: "/opt/golang/go1.13"
1644+
GO_DIST: "/opt/golang/go1.15"
16401645
tasks:
16411646
- name: ".performance"
16421647

@@ -1645,7 +1650,7 @@ buildvariants:
16451650
run_on:
16461651
- ubuntu1604-test
16471652
expansions:
1648-
GO_DIST: "/opt/golang/go1.13"
1653+
GO_DIST: "/opt/golang/go1.15"
16491654
tasks:
16501655
- name: ".compile-check"
16511656

@@ -1654,7 +1659,7 @@ buildvariants:
16541659
run_on:
16551660
- ubuntu1604-build
16561661
expansions:
1657-
GO_DIST: "/opt/golang/go1.13"
1662+
GO_DIST: "/opt/golang/go1.15"
16581663
tasks:
16591664
- name: "atlas-test"
16601665

@@ -1663,7 +1668,7 @@ buildvariants:
16631668
run_on:
16641669
- ubuntu1604-build
16651670
expansions:
1666-
GO_DIST: "/opt/golang/go1.13"
1671+
GO_DIST: "/opt/golang/go1.15"
16671672
tasks:
16681673
- name: "test-atlas-data-lake"
16691674

@@ -1717,22 +1722,22 @@ buildvariants:
17171722
- name: "aws-auth-test"
17181723

17191724
- matrix_name: "ocsp-test"
1720-
matrix_spec: { version: ["4.4", "latest"], os-ssl-32: ["ubuntu1604-64-go-1-13"] }
1725+
matrix_spec: { version: ["4.4", "latest"], os-ssl-32: ["ubuntu1604-64-go-1-15"] }
17211726
display_name: "OCSP ${version} ${os-ssl-32}"
17221727
batchtime: 20160 # 14 days
17231728
tasks:
17241729
- name: ".ocsp"
17251730

17261731
- matrix_name: "ocsp-test-windows"
1727-
matrix_spec: { version: ["4.4", "latest"], os-ssl-32: ["windows-64-go-1-13"] }
1732+
matrix_spec: { version: ["4.4", "latest"], os-ssl-32: ["windows-64-go-1-15"] }
17281733
display_name: "OCSP ${version} ${os-ssl-32}"
17291734
batchtime: 20160 # 14 days
17301735
tasks:
17311736
# Windows MongoDB servers do not staple OCSP responses and only support RSA.
17321737
- name: ".ocsp-rsa !.ocsp-staple"
17331738

17341739
- matrix_name: "ocsp-test-macos"
1735-
matrix_spec: { version: ["4.4", "latest"], os-ssl-32: ["osx-go-1-13"] }
1740+
matrix_spec: { version: ["4.4", "latest"], os-ssl-32: ["osx-go-1-15"] }
17361741
display_name: "OCSP ${version} ${os-ssl-32}"
17371742
batchtime: 20160 # 14 days
17381743
tasks:

bson/bson_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ func noerr(t *testing.T, err error) {
3030
}
3131
}
3232

33-
func requireErrEqual(t *testing.T, err1 error, err2 error) { require.True(t, compareErrors(err1, err2)) }
33+
func requireErrEqual(t *testing.T, err1 error, err2 error) {
34+
require.True(t, compareErrors(err1, err2))
35+
}
3436

3537
func TestTimeRoundTrip(t *testing.T) {
3638
val := struct {

bson/raw_value.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ func (rv RawValue) UnmarshalWithContext(dc *bsoncodec.DecodeContext, val interfa
104104
}
105105

106106
func convertFromCoreValue(v bsoncore.Value) RawValue { return RawValue{Type: v.Type, Value: v.Data} }
107-
func convertToCoreValue(v RawValue) bsoncore.Value { return bsoncore.Value{Type: v.Type, Data: v.Value} }
107+
func convertToCoreValue(v RawValue) bsoncore.Value {
108+
return bsoncore.Value{Type: v.Type, Data: v.Value}
109+
}
108110

109111
// Validate ensures the value is a valid BSON value.
110112
func (rv RawValue) Validate() error { return convertToCoreValue(rv).Validate() }
@@ -176,7 +178,9 @@ func (rv RawValue) ObjectID() primitive.ObjectID { return convertToCoreValue(rv)
176178

177179
// ObjectIDOK is the same as ObjectID, except it returns a boolean instead of
178180
// panicking.
179-
func (rv RawValue) ObjectIDOK() (primitive.ObjectID, bool) { return convertToCoreValue(rv).ObjectIDOK() }
181+
func (rv RawValue) ObjectIDOK() (primitive.ObjectID, bool) {
182+
return convertToCoreValue(rv).ObjectIDOK()
183+
}
180184

181185
// Boolean returns the boolean value the Value represents. It panics if the
182186
// value is a BSON type other than boolean.
@@ -214,7 +218,9 @@ func (rv RawValue) RegexOK() (pattern, options string, ok bool) {
214218

215219
// DBPointer returns the BSON dbpointer value the Value represents. It panics if the value is a BSON
216220
// type other than DBPointer.
217-
func (rv RawValue) DBPointer() (string, primitive.ObjectID) { return convertToCoreValue(rv).DBPointer() }
221+
func (rv RawValue) DBPointer() (string, primitive.ObjectID) {
222+
return convertToCoreValue(rv).DBPointer()
223+
}
218224

219225
// DBPointerOK is the same as DBPoitner, except that it returns a boolean
220226
// instead of panicking.

mongo/mongo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func TestMongoHelpers(t *testing.T) {
116116
got, id, err := transformAndEnsureID(bson.DefaultRegistry, doc)
117117
assert.Nil(t, err, "transformAndEnsureID error: %v", err)
118118
_, ok := id.(string)
119-
assert.True(t, ok, "expected returned id type %T, got %T", string(0), id)
119+
assert.True(t, ok, "expected returned id type string, got %T", id)
120120
assert.Equal(t, got, want, "expected document %v, got %v", got, want)
121121
})
122122
})

x/bsonx/bsoncore/bsoncore.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@ import (
3939
// EmptyDocumentLength is the length of a document that has been started/ended but has no elements.
4040
const EmptyDocumentLength = 5
4141

42+
// nullTerminator is a string version of the 0 byte that is appended at the end of cstrings.
43+
const nullTerminator = string(byte(0))
44+
4245
// AppendType will append t to dst and return the extended buffer.
4346
func AppendType(dst []byte, t bsontype.Type) []byte { return append(dst, byte(t)) }
4447

4548
// AppendKey will append key to dst and return the extended buffer.
46-
func AppendKey(dst []byte, key string) []byte { return append(dst, key+string(0x00)...) }
49+
func AppendKey(dst []byte, key string) []byte { return append(dst, key+nullTerminator...) }
4750

4851
// AppendHeader will append Type t and key to dst and return the extended
4952
// buffer.
@@ -427,7 +430,7 @@ func AppendNullElement(dst []byte, key string) []byte { return AppendHeader(dst,
427430

428431
// AppendRegex will append pattern and options to dst and return the extended buffer.
429432
func AppendRegex(dst []byte, pattern, options string) []byte {
430-
return append(dst, pattern+string(0x00)+options+string(0x00)...)
433+
return append(dst, pattern+nullTerminator+options+nullTerminator...)
431434
}
432435

433436
// AppendRegexElement will append a BSON regex element using key, pattern, and

x/mongo/driver/wiremessage/wiremessage.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,9 @@ func ReadCompressedOriginalOpCode(src []byte) (opcode OpCode, rem []byte, ok boo
490490

491491
// ReadCompressedUncompressedSize reads the uncompressed size of a
492492
// compressed wiremessage to dst.
493-
func ReadCompressedUncompressedSize(src []byte) (size int32, rem []byte, ok bool) { return readi32(src) }
493+
func ReadCompressedUncompressedSize(src []byte) (size int32, rem []byte, ok bool) {
494+
return readi32(src)
495+
}
494496

495497
// ReadCompressedCompressorID reads the ID of the compressor to dst.
496498
func ReadCompressedCompressorID(src []byte) (id CompressorID, rem []byte, ok bool) {

0 commit comments

Comments
 (0)