Skip to content

Commit 026b1cd

Browse files
kylecarbscoadler
andauthored
chore: update to go 1.20 (#5968)
Co-authored-by: Colin Adler <colin1adler@gmail.com>
1 parent 4df1031 commit 026b1cd

File tree

24 files changed

+91
-93
lines changed

24 files changed

+91
-93
lines changed

.devcontainer/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ RUN mkdir -p /etc/apt/keyrings \
5757
&& echo '{"cgroup-parent":"/actions_job","storage-driver":"vfs"}' >> /etc/docker/daemon.json
5858

5959
# install golang and language tooling
60-
ENV GO_VERSION=1.19
60+
ENV GO_VERSION=1.20
6161
ENV GOPATH=$HOME/go-packages
6262
ENV GOROOT=$HOME/go
6363
ENV PATH=$GOROOT/bin:$GOPATH/bin:$PATH

.github/workflows/ci.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
# Install Go!
3838
- uses: actions/setup-go@v3
3939
with:
40-
go-version: "~1.19"
40+
go-version: "~1.20"
4141

4242
# Check for any typos!
4343
- name: Check for typos
@@ -55,7 +55,7 @@ jobs:
5555
- name: Lint Go
5656
uses: golangci/golangci-lint-action@v3.3.1
5757
with:
58-
version: v1.48.0
58+
version: v1.51.0
5959

6060
- name: Lint shell scripts
6161
uses: ludeeus/action-shellcheck@2.0.0
@@ -151,7 +151,7 @@ jobs:
151151

152152
- uses: actions/setup-go@v3
153153
with:
154-
go-version: "~1.19"
154+
go-version: "~1.20"
155155

156156
- name: Echo Go Cache Paths
157157
id: go-cache-paths
@@ -250,7 +250,7 @@ jobs:
250250

251251
- uses: actions/setup-go@v3
252252
with:
253-
go-version: "~1.19"
253+
go-version: "~1.20"
254254

255255
# Sadly the new "set output" syntax (of writing env vars to
256256
# $GITHUB_OUTPUT) does not work on both powershell and bash so we use the
@@ -333,7 +333,7 @@ jobs:
333333

334334
- uses: actions/setup-go@v3
335335
with:
336-
go-version: "~1.19"
336+
go-version: "~1.20"
337337

338338
- name: Echo Go Cache Paths
339339
id: go-cache-paths
@@ -416,7 +416,7 @@ jobs:
416416

417417
- uses: actions/setup-go@v3
418418
with:
419-
go-version: "~1.19"
419+
go-version: "~1.20"
420420

421421
- name: Echo Go Cache Paths
422422
id: go-cache-paths
@@ -545,7 +545,7 @@ jobs:
545545

546546
- uses: actions/setup-go@v3
547547
with:
548-
go-version: "~1.19"
548+
go-version: "~1.20"
549549

550550
- uses: hashicorp/setup-terraform@v2
551551
with:

.github/workflows/release.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191

9292
- uses: actions/setup-go@v3
9393
with:
94-
go-version: "~1.19"
94+
go-version: "~1.20"
9595

9696
- name: Cache Node
9797
id: cache-node

.github/workflows/security.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Setup Go
3939
uses: actions/setup-go@v3
4040
with:
41-
go-version: "~1.19"
41+
go-version: "~1.20"
4242

4343
- name: Go Cache Paths
4444
id: go-cache-paths
@@ -68,7 +68,7 @@ jobs:
6868

6969
- uses: actions/setup-go@v3
7070
with:
71-
go-version: "~1.19"
71+
go-version: "~1.20"
7272

7373
- name: Go Cache Paths
7474
id: go-cache-paths

cli/gitaskpass.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ func gitAskpass() *cobra.Command {
6969

7070
if token.Password != "" {
7171
if user == "" {
72-
fmt.Fprintln(cmd.OutOrStdout(), token.Username)
72+
_, _ = fmt.Fprintln(cmd.OutOrStdout(), token.Username)
7373
} else {
74-
fmt.Fprintln(cmd.OutOrStdout(), token.Password)
74+
_, _ = fmt.Fprintln(cmd.OutOrStdout(), token.Password)
7575
}
7676
} else {
77-
fmt.Fprintln(cmd.OutOrStdout(), token.Username)
77+
_, _ = fmt.Fprintln(cmd.OutOrStdout(), token.Username)
7878
}
7979

8080
return nil

cli/root_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ var updateGoldenFiles = flag.Bool("update", false, "update .golden files")
3030

3131
//nolint:tparallel,paralleltest // These test sets env vars.
3232
func TestCommandHelp(t *testing.T) {
33-
t.Parallel()
34-
3533
commonEnv := map[string]string{
3634
"CODER_CONFIG_DIR": "/tmp/coder-cli-test-config",
3735
}

coderd/httpmw/ratelimit_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
func randRemoteAddr() string {
2525
var b [4]byte
2626
// nolint:gosec
27-
rand.Read(b[:])
27+
_, _ = rand.Read(b[:])
2828
// nolint:gosec
2929
return fmt.Sprintf("%s:%v", net.IP(b[:]).String(), rand.Int31()%(1<<16))
3030
}

coderd/rbac/builtin_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ func TestIsOrgRole(t *testing.T) {
360360

361361
// nolint:paralleltest
362362
for _, c := range testCases {
363+
c := c
363364
t.Run(c.RoleName, func(t *testing.T) {
364365
t.Parallel()
365366
orgID, ok := rbac.IsOrgRole(c.RoleName)

coderd/rbac/regosql/compile.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ func ConvertRegoAst(cfg ConvertConfig, partial *rego.PartialQueries) (sqltypes.B
4646
}
4747

4848
if i != 0 {
49-
builder.WriteString("\n")
49+
_, _ = builder.WriteString("\n")
5050
}
51-
builder.WriteString(q.String())
51+
_, _ = builder.WriteString(q.String())
5252
queries = append(queries, converted)
5353
}
5454

coderd/updatecheck/updatecheck_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func TestChecker_Notify(t *testing.T) {
4444

4545
w.Header().Set("Content-Type", "application/json")
4646
w.WriteHeader(http.StatusOK)
47-
w.Write(b)
47+
_, _ = w.Write(b)
4848
}
4949
}))
5050
defer srv.Close()

dogfood/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ FROM ubuntu AS go
88

99
RUN apt-get update && apt-get install --yes curl gcc
1010
# Install Go manually, so that we can control the version
11-
ARG GO_VERSION=1.19
11+
ARG GO_VERSION=1.20
1212
RUN mkdir --parents /usr/local/go
1313

1414
# Boring Go is needed to build FIPS-compliant binaries.
@@ -210,7 +210,7 @@ RUN systemctl enable \
210210
ARG CLOUD_SQL_PROXY_VERSION=1.26.0 \
211211
DIVE_VERSION=0.10.0 \
212212
DOCKER_GCR_VERSION=2.1.0 \
213-
GOLANGCI_LINT_VERSION=1.48.0 \
213+
GOLANGCI_LINT_VERSION=1.51.0 \
214214
GRYPE_VERSION=0.24.0 \
215215
HELM_VERSION=3.8.0 \
216216
KUBE_LINTER_VERSION=0.2.5 \

dogfood/files/etc/apt/preferences.d/docker

-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@ Pin-Priority: 500
1616
# containerd runtime
1717
Package: containerd.io
1818
Pin: origin download.docker.com
19-
Pin: version 1.5.11-1
2019
Pin-Priority: 500
578 Bytes
Binary file not shown.
-1.07 KB
Binary file not shown.

enterprise/audit/diff_internal_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ func Test_diff(t *testing.T) {
317317
},
318318
exp: audit.Map{
319319
"id": audit.OldNew{Old: "", New: uuid.UUID{1}.String()},
320-
"template_id": audit.OldNew{Old: "", New: uuid.UUID{2}.String()},
320+
"template_id": audit.OldNew{Old: "null", New: uuid.UUID{2}.String()},
321321
"created_by": audit.OldNew{Old: "", New: uuid.UUID{4}.String()},
322322
"name": audit.OldNew{Old: "", New: "rust"},
323323
},
@@ -386,7 +386,7 @@ func Test_diff(t *testing.T) {
386386
"owner_id": audit.OldNew{Old: "", New: uuid.UUID{2}.String()},
387387
"template_id": audit.OldNew{Old: "", New: uuid.UUID{3}.String()},
388388
"name": audit.OldNew{Old: "", New: "rust workspace"},
389-
"autostart_schedule": audit.OldNew{Old: "", New: "0 12 * * 1-5"},
389+
"autostart_schedule": audit.OldNew{Old: "null", New: "0 12 * * 1-5"},
390390
"ttl": audit.OldNew{Old: int64(0), New: int64(8 * time.Hour)}, // XXX: pq still does not support time.Duration
391391
},
392392
},
@@ -417,8 +417,8 @@ func runDiffTests(t *testing.T, tests []diffTest) {
417417
t.Helper()
418418

419419
for _, test := range tests {
420+
test := test
420421
typName := reflect.TypeOf(test.left).Name()
421-
422422
t.Run(typName+"/"+test.name, func(t *testing.T) {
423423
t.Parallel()
424424
require.Equal(t,

enterprise/tailnet/coordinator.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,9 @@ func (c *haCoordinator) handlePubsubMessage(ctx context.Context, message []byte)
568568
func (c *haCoordinator) formatCallMeMaybe(recipient uuid.UUID, nodes []*agpl.Node) ([]byte, error) {
569569
buf := bytes.Buffer{}
570570

571-
buf.WriteString(c.id.String() + "|")
572-
buf.WriteString("callmemaybe|")
573-
buf.WriteString(recipient.String() + "|")
571+
_, _ = buf.WriteString(c.id.String() + "|")
572+
_, _ = buf.WriteString("callmemaybe|")
573+
_, _ = buf.WriteString(recipient.String() + "|")
574574
err := json.NewEncoder(&buf).Encode(nodes)
575575
if err != nil {
576576
return nil, xerrors.Errorf("encode node: %w", err)
@@ -583,9 +583,9 @@ func (c *haCoordinator) formatCallMeMaybe(recipient uuid.UUID, nodes []*agpl.Nod
583583
func (c *haCoordinator) formatAgentHello(id uuid.UUID) ([]byte, error) {
584584
buf := bytes.Buffer{}
585585

586-
buf.WriteString(c.id.String() + "|")
587-
buf.WriteString("agenthello|")
588-
buf.WriteString(id.String() + "|")
586+
_, _ = buf.WriteString(c.id.String() + "|")
587+
_, _ = buf.WriteString("agenthello|")
588+
_, _ = buf.WriteString(id.String() + "|")
589589

590590
return buf.Bytes(), nil
591591
}
@@ -594,9 +594,9 @@ func (c *haCoordinator) formatAgentHello(id uuid.UUID) ([]byte, error) {
594594
func (c *haCoordinator) formatClientHello(id uuid.UUID) ([]byte, error) {
595595
buf := bytes.Buffer{}
596596

597-
buf.WriteString(c.id.String() + "|")
598-
buf.WriteString("clienthello|")
599-
buf.WriteString(id.String() + "|")
597+
_, _ = buf.WriteString(c.id.String() + "|")
598+
_, _ = buf.WriteString("clienthello|")
599+
_, _ = buf.WriteString(id.String() + "|")
600600

601601
return buf.Bytes(), nil
602602
}
@@ -605,9 +605,9 @@ func (c *haCoordinator) formatClientHello(id uuid.UUID) ([]byte, error) {
605605
func (c *haCoordinator) formatAgentUpdate(id uuid.UUID, node *agpl.Node) ([]byte, error) {
606606
buf := bytes.Buffer{}
607607

608-
buf.WriteString(c.id.String() + "|")
609-
buf.WriteString("agentupdate|")
610-
buf.WriteString(id.String() + "|")
608+
_, _ = buf.WriteString(c.id.String() + "|")
609+
_, _ = buf.WriteString("agentupdate|")
610+
_, _ = buf.WriteString(id.String() + "|")
611611
err := json.NewEncoder(&buf).Encode(node)
612612
if err != nil {
613613
return nil, xerrors.Errorf("encode node: %w", err)
@@ -622,8 +622,8 @@ func (c *haCoordinator) ServeHTTPDebug(w http.ResponseWriter, r *http.Request) {
622622
c.mutex.RLock()
623623
defer c.mutex.RUnlock()
624624

625-
fmt.Fprintln(w, "<h1>high-availability wireguard coordinator debug</h1>")
626-
fmt.Fprintln(w, "<h4 style=\"margin-top:-25px\">warning: this only provides info from the node that served the request, if there are multiple replicas this data may be incomplete</h4>")
625+
_, _ = fmt.Fprintln(w, "<h1>high-availability wireguard coordinator debug</h1>")
626+
_, _ = fmt.Fprintln(w, "<h4 style=\"margin-top:-25px\">warning: this only provides info from the node that served the request, if there are multiple replicas this data may be incomplete</h4>")
627627

628628
agpl.CoordinatorHTTPDebug(c.agentSockets, c.agentToConnectionSockets, c.agentNameCache)(w, r)
629629
}

flake.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
getopt
2525
git
2626
go-migrate
27-
go_1_19
27+
go_1_20
2828
golangci-lint
2929
gopls
3030
gotestsum

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/coder/coder
22

3-
go 1.19
3+
go 1.20
44

55
// Required until https://github.com/manifoldco/promptui/pull/169 is merged.
66
replace github.com/manifoldco/promptui => github.com/kylecarbs/promptui v0.8.1-0.20201231190244-d8f2159af2b2

provisioner/terraform/safeenv.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
const unsafeEnvCanary = "CODER_DONT_PASS"
2020

2121
func init() {
22-
os.Setenv(unsafeEnvCanary, "true")
22+
_ = os.Setenv(unsafeEnvCanary, "true")
2323
}
2424

2525
func envName(env string) string {

scripts/apitypings/main.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func main() {
3737
}
3838

3939
// Just cat the output to a file to capture it
40-
fmt.Println(output)
40+
_, _ = fmt.Println(output)
4141
}
4242

4343
func Generate(directory string) (string, error) {
@@ -307,11 +307,11 @@ func (g *Generator) generateOne(m *Maps, obj types.Object) error {
307307
var str strings.Builder
308308
_, _ = str.WriteString(g.posLine(obj))
309309
if ts.AboveTypeLine != "" {
310-
str.WriteString(ts.AboveTypeLine)
311-
str.WriteRune('\n')
310+
_, _ = str.WriteString(ts.AboveTypeLine)
311+
_, _ = str.WriteRune('\n')
312312
}
313313
// Use similar output syntax to enums.
314-
str.WriteString(fmt.Sprintf("export type %s = %s\n", obj.Name(), ts.ValueType))
314+
_, _ = str.WriteString(fmt.Sprintf("export type %s = %s\n", obj.Name(), ts.ValueType))
315315
m.Structs[obj.Name()] = str.String()
316316
case *types.Interface:
317317
// Interfaces are used as generics. Non-generic interfaces are
@@ -353,7 +353,7 @@ func (g *Generator) generateOne(m *Maps, obj types.Object) error {
353353
case *types.Func:
354354
// Noop
355355
default:
356-
fmt.Println(obj.Name())
356+
_, _ = fmt.Println(obj.Name())
357357
}
358358
return nil
359359
}
@@ -387,7 +387,7 @@ func (g *Generator) buildUnion(obj types.Object, st *types.Union) (string, error
387387

388388
allTypes = slice.Unique(allTypes)
389389

390-
s.WriteString(fmt.Sprintf("export type %s = %s\n", obj.Name(), strings.Join(allTypes, " | ")))
390+
_, _ = s.WriteString(fmt.Sprintf("export type %s = %s\n", obj.Name(), strings.Join(allTypes, " | ")))
391391

392392
return s.String(), nil
393393
}

scripts/auditdocgen/main.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ func updateAuditDoc(doc []byte, auditableResourcesMap AuditableResourcesMap) ([]
110110
tableEndIndex := tableStartIndex + j
111111

112112
var buffer bytes.Buffer
113-
buffer.Write(doc[:tableStartIndex])
114-
buffer.WriteByte('\n')
113+
_, _ = buffer.Write(doc[:tableStartIndex])
114+
_ = buffer.WriteByte('\n')
115115

116-
buffer.WriteString("|<b>Resource<b>||\n")
117-
buffer.WriteString("|--|-----------------|\n")
116+
_, _ = buffer.WriteString("|<b>Resource<b>||\n")
117+
_, _ = buffer.WriteString("|--|-----------------|\n")
118118

119119
for _, resourceName := range sortedResourceNames {
120120
readableResourceName := resourceName
@@ -131,21 +131,21 @@ func updateAuditDoc(doc []byte, auditableResourcesMap AuditableResourcesMap) ([]
131131
}
132132
auditActionsString := strings.Join(auditActions, ", ")
133133

134-
buffer.WriteString("|" + readableResourceName + "<br><i>" + auditActionsString + "</i>|<table><thead><tr><th>Field</th><th>Tracked</th></tr></thead><tbody>")
134+
_, _ = buffer.WriteString("|" + readableResourceName + "<br><i>" + auditActionsString + "</i>|<table><thead><tr><th>Field</th><th>Tracked</th></tr></thead><tbody>")
135135

136136
// We must sort the field names to ensure sub-table ordering
137137
sortedFieldNames := sortKeys(auditableResourcesMap[resourceName])
138138

139139
for _, fieldName := range sortedFieldNames {
140140
isTracked := auditableResourcesMap[resourceName][fieldName]
141-
buffer.WriteString("<tr><td>" + fieldName + "</td><td>" + strconv.FormatBool(isTracked) + "</td></tr>")
141+
_, _ = buffer.WriteString("<tr><td>" + fieldName + "</td><td>" + strconv.FormatBool(isTracked) + "</td></tr>")
142142
}
143143

144-
buffer.WriteString("</tbody></table>\n")
144+
_, _ = buffer.WriteString("</tbody></table>\n")
145145
}
146146

147-
buffer.WriteString("\n")
148-
buffer.Write(doc[tableEndIndex:])
147+
_, _ = buffer.WriteString("\n")
148+
_, _ = buffer.Write(doc[tableEndIndex:])
149149
return buffer.Bytes(), nil
150150
}
151151

0 commit comments

Comments
 (0)