Skip to content

Commit be8389f

Browse files
authored
chore: update to go 1.18 (coder#628)
* add make lint to Makefile
1 parent b33dec9 commit be8389f

File tree

13 files changed

+35
-561
lines changed

13 files changed

+35
-561
lines changed

.github/workflows/coder-test-stability.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ on:
1414
workflow_dispatch:
1515
inputs:
1616
iterationCount:
17-
description: 'Iteration Count'
17+
description: "Iteration Count"
1818
required: false
19-
default: '10'
19+
default: "10"
2020

2121
# Cancel in-progress runs for pull requests when developers push
2222
# additional changes, and serialize builds in branches.
@@ -43,7 +43,7 @@ jobs:
4343

4444
- uses: actions/setup-go@v2
4545
with:
46-
go-version: "^1.17"
46+
go-version: "~1.18"
4747

4848
- uses: actions/cache@v3
4949
with:

.github/workflows/coder.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
- name: golangci-lint
4545
uses: golangci/golangci-lint-action@v3.1.0
4646
with:
47-
version: v1.43.0
47+
version: v1.45.2
4848

4949
style-lint-typescript:
5050
name: "style/lint/typescript"
@@ -201,7 +201,7 @@ jobs:
201201

202202
- uses: actions/setup-go@v2
203203
with:
204-
go-version: "~1.17"
204+
go-version: "~1.18"
205205

206206
- name: Echo Go Cache Paths
207207
id: go-cache-paths
@@ -299,7 +299,7 @@ jobs:
299299

300300
- uses: actions/setup-go@v2
301301
with:
302-
go-version: "~1.17"
302+
go-version: "~1.18"
303303

304304
- name: Echo Go Cache Paths
305305
id: go-cache-paths
@@ -362,7 +362,7 @@ jobs:
362362
# Go is required for uploading the test results to datadog
363363
- uses: actions/setup-go@v2
364364
with:
365-
go-version: "~1.17"
365+
go-version: "~1.18"
366366

367367
- uses: actions/setup-node@v3
368368
with:

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
fetch-depth: 0
1313
- uses: actions/setup-go@v2
1414
with:
15-
go-version: "^1.17"
15+
go-version: "~1.18"
1616

1717
- name: Run GoReleaser
1818
uses: goreleaser/goreleaser-action@v2.9.1

.golangci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ linters-settings:
154154
- name: import-shadowing
155155
- name: increment-decrement
156156
- name: indent-error-flow
157-
- name: modifies-parameter
157+
# - name: modifies-parameter
158158
- name: modifies-value-receiver
159159
- name: package-comments
160160
- name: range
@@ -185,6 +185,8 @@ linters-settings:
185185
- i
186186
- db
187187
- t
188+
- id
189+
- wg
188190
# Optional list of variable declarations that should be ignored completely. (defaults to empty list)
189191
# Entries must be in the form of "<variable name> <type>" or "<variable name> *<type>" for
190192
# variables, or "const <name>" for constants.
@@ -193,6 +195,8 @@ linters-settings:
193195
- r *http.Request
194196
- t testing.T
195197
- t testing.TB
198+
- ok bool
199+
- wg sync.WaitGroup
196200

197201
issues:
198202
# Rules listed here: https://github.com/securego/gosec#available-rules

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,8 @@ site/out:
8888
# Restores GITKEEP files!
8989
git checkout HEAD site/out
9090
.PHONY: site/out
91+
92+
lint:
93+
@echo "--- golangci-lint"
94+
golangci-lint run
95+
.PHONY: lint

cli/cliui/select.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ func Select(cmd *cobra.Command, opts SelectOptions) (string, error) {
3535
Templates: &promptui.SelectTemplates{
3636
FuncMap: template.FuncMap{
3737
"faint": func(value interface{}) string {
38+
//nolint:forcetypeassert
3839
return Styles.Placeholder.Render(value.(string))
3940
},
4041
"subtle": func(value interface{}) string {
42+
//nolint:forcetypeassert
4143
return defaultStyles.Subtle.Render(value.(string))
4244
},
4345
"selected": func(value interface{}) string {
46+
//nolint:forcetypeassert
4447
return defaultStyles.Keyword.Render("> " + value.(string))
4548
// return defaultStyles.SelectedMenuItem.Render("> " + value.(string))
4649
},

coderd/database/postgres/postgres.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,7 @@ func getFreePort() (port int, err error) {
138138
}
139139

140140
defer listener.Close()
141+
// This is always a *net.TCPAddr.
142+
// nolint:forcetypeassert
141143
return listener.Addr().(*net.TCPAddr).Port, nil
142144
}

coderd/database/pubsub.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ func (p *pgPubsub) Subscribe(event string, listener Listener) (cancel func(), er
7272
}
7373

7474
func (p *pgPubsub) Publish(event string, message []byte) error {
75+
// This is safe because we are calling pq.QuoteLiteral. pg_notify doesn't
76+
// support the first parameter being a prepared statement.
77+
//nolint:gosec
7578
_, err := p.db.ExecContext(context.Background(), `select pg_notify(`+pq.QuoteLiteral(event)+`, $1)`, message)
7679
if err != nil {
7780
return xerrors.Errorf("exec: %w", err)

coderd/provisionerjobs.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ func (api *api) provisionerJobLogs(rw http.ResponseWriter, r *http.Request, job
138138
// See: https://canjs.com/doc/can-ndjson-stream.html
139139
rw.Header().Set("Content-Type", "application/stream+json")
140140
rw.WriteHeader(http.StatusOK)
141-
rw.(http.Flusher).Flush()
141+
if flusher, ok := rw.(http.Flusher); ok {
142+
flusher.Flush()
143+
}
142144

143145
// The Go stdlib JSON encoder appends a newline character after message write.
144146
encoder := json.NewEncoder(rw)
@@ -161,7 +163,9 @@ func (api *api) provisionerJobLogs(rw http.ResponseWriter, r *http.Request, job
161163
if err != nil {
162164
return
163165
}
164-
rw.(http.Flusher).Flush()
166+
if flusher, ok := rw.(http.Flusher); ok {
167+
flusher.Flush()
168+
}
165169
case <-ticker.C:
166170
job, err := api.Database.GetProvisionerJobByID(r.Context(), job.ID)
167171
if err != nil {

codersdk/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ func readBodyAsError(res *http.Response) error {
9494
}
9595
}
9696

97+
//nolint:varnamelen
9798
var m httpapi.Response
9899
err := json.NewDecoder(res.Body).Decode(&m)
99100
if err != nil {

go.mod

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

3-
go 1.17
3+
go 1.18
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

0 commit comments

Comments
 (0)