Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb0fe9bc

Browse files
authored
chore: Upgrade to Go 1.19 (#3617)
This is required as part of#3505.
1 parentd37fb05 commitb0fe9bc

File tree

52 files changed

+144
-86
lines changed

Some content is hidden

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

52 files changed

+144
-86
lines changed

‎.github/workflows/coder.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ jobs:
9696
-uses:actions/checkout@v3
9797
-uses:actions/setup-go@v3
9898
with:
99-
go-version:"~1.18"
99+
go-version:"~1.19"
100100
-name:golangci-lint
101101
uses:golangci/golangci-lint-action@v3.2.0
102102
with:
103-
version:v1.46.0
103+
version:v1.48.0
104104

105105
check-enterprise-imports:
106106
name:check/enterprise-imports
@@ -199,7 +199,7 @@ jobs:
199199
version:"3.20.0"
200200
-uses:actions/setup-go@v3
201201
with:
202-
go-version:"~1.18"
202+
go-version:"~1.19"
203203

204204
-name:Echo Go Cache Paths
205205
id:go-cache-paths
@@ -283,7 +283,7 @@ jobs:
283283

284284
-uses:actions/setup-go@v3
285285
with:
286-
go-version:"~1.18"
286+
go-version:"~1.19"
287287

288288
-name:Echo Go Cache Paths
289289
id:go-cache-paths
@@ -370,7 +370,7 @@ jobs:
370370

371371
-uses:actions/setup-go@v3
372372
with:
373-
go-version:"~1.18"
373+
go-version:"~1.19"
374374

375375
-name:Echo Go Cache Paths
376376
id:go-cache-paths
@@ -453,7 +453,7 @@ jobs:
453453

454454
-uses:actions/setup-go@v3
455455
with:
456-
go-version:"~1.18"
456+
go-version:"~1.19"
457457

458458
-name:Echo Go Cache Paths
459459
id:go-cache-paths
@@ -558,7 +558,7 @@ jobs:
558558
# Go is required for uploading the test results to datadog
559559
-uses:actions/setup-go@v3
560560
with:
561-
go-version:"~1.18"
561+
go-version:"~1.19"
562562

563563
-uses:actions/setup-node@v3
564564
with:
@@ -616,7 +616,7 @@ jobs:
616616
# Go is required for uploading the test results to datadog
617617
-uses:actions/setup-go@v3
618618
with:
619-
go-version:"~1.18"
619+
go-version:"~1.19"
620620

621621
-uses:hashicorp/setup-terraform@v2
622622
with:

‎.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"cSpell.words": [
33
"apps",
44
"awsidentity",
5+
"bodyclose",
56
"buildinfo",
67
"buildname",
78
"circbuf",
@@ -52,6 +53,7 @@
5253
"ntqry",
5354
"OIDC",
5455
"oneof",
56+
"paralleltest",
5557
"parameterscopeid",
5658
"pqtype",
5759
"prometheusmetrics",
@@ -80,6 +82,7 @@
8082
"tfjson",
8183
"tfplan",
8284
"tfstate",
85+
"tparallel",
8386
"trimprefix",
8487
"turnconn",
8588
"typegen",

‎agent/reaper/reaper_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func TestReap(t *testing.T) {
2929
// exited processes and passing the PIDs through the shared
3030
// channel.
3131
t.Run("OK",func(t*testing.T) {
32+
t.Parallel()
3233
pids:=make(reap.PidCh,1)
3334
err:=reaper.ForkReap(
3435
reaper.WithPIDCallback(pids),

‎cli/cliflag/cliflag.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
//
77
// Will produce the following usage docs:
88
//
9-
// -a, --address string The address to serve the API and dashboard (uses $CODER_ADDRESS). (default "127.0.0.1:3000")
10-
//
9+
//-a, --address string The address to serve the API and dashboard (uses $CODER_ADDRESS). (default "127.0.0.1:3000")
1110
package cliflag
1211

1312
import (

‎cli/cliflag/cliflag_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
)
1515

1616
// Testcliflag cannot run in parallel because it uses t.Setenv.
17+
//
1718
//nolint:paralleltest
1819
funcTestCliflag(t*testing.T) {
1920
t.Run("StringDefault",func(t*testing.T) {

‎cli/configssh.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ func currentBinPath(w io.Writer) (string, error) {
558558

559559
// diffBytes takes two byte slices and diffs them as if they were in a
560560
// file named name.
561-
//nolint: revive // Color is an option, not a control coupling.
561+
//nolint: revive // Color is an option, not a control coupling.
562562
funcdiffBytes(namestring,b1,b2 []byte,colorbool) ([]byte,error) {
563563
varbuf bytes.Buffer
564564
varopts []write.Option

‎cli/delete_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
)
1616

1717
funcTestDelete(t*testing.T) {
18+
t.Parallel()
1819
t.Run("WithParameter",func(t*testing.T) {
1920
t.Parallel()
2021
client:=coderdtest.New(t,&coderdtest.Options{IncludeProvisionerD:true})

‎cli/gitssh_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
funcTestGitSSH(t*testing.T) {
2323
t.Parallel()
2424
t.Run("Dial",func(t*testing.T) {
25+
t.Parallel()
2526
client:=coderdtest.New(t,&coderdtest.Options{IncludeProvisionerD:true})
2627
user:=coderdtest.CreateFirstUser(t,client)
2728

‎cli/publickey_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
funcTestPublicKey(t*testing.T) {
1414
t.Parallel()
1515
t.Run("OK",func(t*testing.T) {
16+
t.Parallel()
1617
client:=coderdtest.New(t,nil)
1718
_=coderdtest.CreateFirstUser(t,client)
1819
cmd,root:=clitest.New(t,"publickey")

‎cli/root_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
)
1616

1717
funcTestRoot(t*testing.T) {
18+
t.Parallel()
1819
t.Run("FormatCobraError",func(t*testing.T) {
1920
t.Parallel()
2021

‎cli/server.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,9 @@ func server() *cobra.Command {
475475
server:=&http.Server{
476476
// These errors are typically noise like "TLS: EOF". Vault does similar:
477477
// https://github.com/hashicorp/vault/blob/e2490059d0711635e529a4efcbaa1b26998d6e1c/command/server.go#L2714
478-
ErrorLog:log.New(io.Discard,"",0),
479-
Handler:coderAPI.Handler,
478+
ErrorLog:log.New(io.Discard,"",0),
479+
Handler:coderAPI.Handler,
480+
ReadHeaderTimeout:time.Minute,
480481
BaseContext:func(_ net.Listener) context.Context {
481482
returnshutdownConnsCtx
482483
},
@@ -1080,7 +1081,11 @@ func configureGithubOAuth2(accessURL *url.URL, clientID, clientSecret string, al
10801081
funcserveHandler(ctx context.Context,logger slog.Logger,handler http.Handler,addr,namestring) (closeFuncfunc()) {
10811082
logger.Debug(ctx,"http server listening",slog.F("addr",addr),slog.F("name",name))
10821083

1083-
srv:=&http.Server{Addr:addr,Handler:handler}
1084+
srv:=&http.Server{
1085+
Addr:addr,
1086+
Handler:handler,
1087+
ReadHeaderTimeout:time.Minute,
1088+
}
10841089
gofunc() {
10851090
err:=srv.ListenAndServe()
10861091
iferr!=nil&&!xerrors.Is(err,http.ErrServerClosed) {

‎cli/server_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
)
4040

4141
// This cannot be ran in parallel because it uses a signal.
42-
// nolint:paralleltest
42+
// nolint:tparallel,paralleltest
4343
funcTestServer(t*testing.T) {
4444
t.Run("Production",func(t*testing.T) {
4545
ifruntime.GOOS!="linux"||testing.Short() {
@@ -410,6 +410,7 @@ func TestServer(t *testing.T) {
410410
require.Eventually(t,func()bool {
411411
req,err:=http.NewRequestWithContext(ctx,"GET",fmt.Sprintf("http://127.0.0.1:%d",randomPort),nil)
412412
assert.NoError(t,err)
413+
// nolint:bodyclose
413414
res,err=http.DefaultClient.Do(req)
414415
returnerr==nil
415416
},testutil.WaitShort,testutil.IntervalFast)
@@ -461,7 +462,9 @@ func TestServer(t *testing.T) {
461462
}
462463
githubURL,err:=accessURL.Parse("/api/v2/users/oauth2/github")
463464
require.NoError(t,err)
464-
res,err:=client.HTTPClient.Get(githubURL.String())
465+
req,err:=http.NewRequestWithContext(ctx,http.MethodGet,githubURL.String(),nil)
466+
require.NoError(t,err)
467+
res,err:=client.HTTPClient.Do(req)
465468
require.NoError(t,err)
466469
deferres.Body.Close()
467470
fakeURL,err:=res.Location()

‎cli/userstatus_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/coder/coder/codersdk"
1313
)
1414

15+
// nolint:tparallel,paralleltest
1516
funcTestUserStatus(t*testing.T) {
1617
t.Parallel()
1718
client:=coderdtest.New(t,nil)
@@ -20,7 +21,6 @@ func TestUserStatus(t *testing.T) {
2021
otherUser,err:=other.User(context.Background(),codersdk.Me)
2122
require.NoError(t,err,"fetch user")
2223

23-
//nolint:paralleltest
2424
t.Run("StatusSelf",func(t*testing.T) {
2525
cmd,root:=clitest.New(t,"users","suspend","me")
2626
clitest.SetupConfig(t,client,root)
@@ -32,7 +32,6 @@ func TestUserStatus(t *testing.T) {
3232
require.ErrorContains(t,err,"cannot suspend yourself")
3333
})
3434

35-
//nolint:paralleltest
3635
t.Run("StatusOther",func(t*testing.T) {
3736
require.Equal(t,otherUser.Status,codersdk.UserStatusActive,"start as active")
3837

‎coderd/audit/diff.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func diffValues[T any](left, right T, table Table) Map {
9999
}
100100

101101
// convertDiffType converts external struct types to primitive types.
102+
//
102103
//nolint:forcetypeassert
103104
funcconvertDiffType(left,rightany) (newLeft,newRightany,changedbool) {
104105
switchtyped:=left.(type) {

‎coderd/audit/diff_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ func runDiffTests[T audit.Auditable](t *testing.T, tests []diffTest[T]) {
230230

231231
for_,test:=rangetests {
232232
t.Run(typName+"/"+test.name,func(t*testing.T) {
233+
t.Parallel()
233234
require.Equal(t,
234235
test.exp,
235236
audit.Diff(test.left,test.right),

‎coderd/authorize.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func AuthorizeFilter[O rbac.Objecter](api *API, r *http.Request, action rbac.Act
3131
// This function will log appropriately, but the caller must return an
3232
// error to the api client.
3333
// Eg:
34+
//
3435
//if !api.Authorize(...) {
3536
//httpapi.Forbidden(rw)
3637
//return

‎coderd/autobuild/notify/notifier.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ type Notifier struct {
2020
}
2121

2222
// Condition is a function that gets executed with a certain time.
23-
// - It should return the deadline for the notification, as well as a
24-
// callback function to execute once the time to the deadline is
25-
// less than one of the notify attempts. If deadline is the zero
26-
// time, callback will not be executed.
27-
// - Callback is executed once for every time the difference between deadline
28-
// and the current time is less than an element of countdown.
29-
// - To enforce a minimum interval between consecutive callbacks, truncate
30-
// the returned deadline to the minimum interval.
23+
//- It should return the deadline for the notification, as well as a
24+
//callback function to execute once the time to the deadline is
25+
//less than one of the notify attempts. If deadline is the zero
26+
//time, callback will not be executed.
27+
//- Callback is executed once for every time the difference between deadline
28+
//and the current time is less than an element of countdown.
29+
//- To enforce a minimum interval between consecutive callbacks, truncate
30+
//the returned deadline to the minimum interval.
3131
typeConditionfunc(now time.Time) (deadline time.Time,callbackfunc())
3232

3333
// Notify is a convenience function that initializes a new Notifier
@@ -44,8 +44,8 @@ func Notify(cond Condition, interval time.Duration, countdown ...time.Duration)
4444
}
4545

4646
// New returns a Notifier that calls cond once every time it polls.
47-
// - Duplicate values are removed from countdown, and it is sorted in
48-
// descending order.
47+
//- Duplicate values are removed from countdown, and it is sorted in
48+
//descending order.
4949
funcNew(condCondition,countdown...time.Duration)*Notifier {
5050
// Ensure countdown is sorted in descending order and contains no duplicates.
5151
ct:=unique(countdown)

‎coderd/autobuild/schedule/schedule.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ var defaultParser = cron.NewParser(parserFormat)
2828
// - day of week e.g. 1 (required)
2929
//
3030
// Example Usage:
31-
// local_sched, _ := schedule.Weekly("59 23 *")
32-
// fmt.Println(sched.Next(time.Now().Format(time.RFC3339)))
33-
// // Output: 2022-04-04T23:59:00Z
3431
//
35-
// us_sched, _ := schedule.Weekly("CRON_TZ=US/Central 30 9 1-5")
36-
// fmt.Println(sched.Next(time.Now()).Format(time.RFC3339))
37-
// // Output: 2022-04-04T14:30:00Z
32+
//local_sched, _ := schedule.Weekly("59 23 *")
33+
//fmt.Println(sched.Next(time.Now().Format(time.RFC3339)))
34+
//// Output: 2022-04-04T23:59:00Z
35+
//
36+
//us_sched, _ := schedule.Weekly("CRON_TZ=US/Central 30 9 1-5")
37+
//fmt.Println(sched.Next(time.Now()).Format(time.RFC3339))
38+
//// Output: 2022-04-04T14:30:00Z
3839
funcWeekly(rawstring) (*Schedule,error) {
3940
iferr:=validateWeeklySpec(raw);err!=nil {
4041
returnnil,xerrors.Errorf("validate weekly schedule: %w",err)
@@ -115,12 +116,12 @@ var tMax = t0.Add(168 * time.Hour)
115116

116117
// Min returns the minimum duration of the schedule.
117118
// This is calculated as follows:
118-
// - Let t(0) be a given point in time (1970-01-01T01:01:01Z00:00)
119-
// - Let t(max) be 168 hours after t(0).
120-
// - Let t(1) be the next scheduled time after t(0).
121-
// - Let t(n) be the next scheduled time after t(n-1).
122-
// - Then, the minimum duration of s d(min)
123-
// = min( t(n) - t(n-1) ∀ n ∈ N, t(n) < t(max) )
119+
//- Let t(0) be a given point in time (1970-01-01T01:01:01Z00:00)
120+
//- Let t(max) be 168 hours after t(0).
121+
//- Let t(1) be the next scheduled time after t(0).
122+
//- Let t(n) be the next scheduled time after t(n-1).
123+
//- Then, the minimum duration of s d(min)
124+
//= min( t(n) - t(n-1) ∀ n ∈ N, t(n) < t(max) )
124125
func (sSchedule)Min() time.Duration {
125126
durMin:=tMax.Sub(t0)
126127
tPrev:=s.Next(t0)

‎coderd/azureidentity/azureidentity.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ func Validate(ctx context.Context, signature string, options x509.VerifyOptions)
5252
}
5353
data,err:=io.ReadAll(res.Body)
5454
iferr!=nil {
55+
_=res.Body.Close()
5556
return"",xerrors.Errorf("read body %q: %w",certURL,err)
5657
}
58+
_=res.Body.Close()
5759
cert,err:=x509.ParseCertificate(data)
5860
iferr!=nil {
5961
return"",xerrors.Errorf("parse certificate %q: %w",certURL,err)

‎coderd/database/pubsub_test.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/coder/coder/coderd/database/postgres"
1515
)
1616

17+
// nolint:tparallel,paralleltest
1718
funcTestPubsub(t*testing.T) {
1819
t.Parallel()
1920

@@ -22,10 +23,7 @@ func TestPubsub(t *testing.T) {
2223
return
2324
}
2425

25-
// nolint:paralleltest
2626
t.Run("Postgres",func(t*testing.T) {
27-
// postgres.Open() seems to be creating race conditions when run in parallel.
28-
// t.Parallel()
2927
ctx,cancelFunc:=context.WithCancel(context.Background())
3028
defercancelFunc()
3129

@@ -54,10 +52,7 @@ func TestPubsub(t *testing.T) {
5452
assert.Equal(t,string(message),data)
5553
})
5654

57-
// nolint:paralleltest
5855
t.Run("PostgresCloseCancel",func(t*testing.T) {
59-
// postgres.Open() seems to be creating race conditions when run in parallel.
60-
// t.Parallel()
6156
ctx,cancelFunc:=context.WithCancel(context.Background())
6257
defercancelFunc()
6358
connectionURL,closePg,err:=postgres.Open()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp