Skip to content

Commit 80fb516

Browse files
authored
all: Update Go Module to Go 1.20 (#1246)
Reference: https://pkg.go.dev/math/rand#Seed Reference: #1245 Previously from `golangci-lint` after Go 1.20 upgrade: ``` helper/acctest/random.go:24:2: SA1019: rand.Seed has been deprecated since Go 1.20 and an alternative has been available since Go 1.0: As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator. (staticcheck) rand.Seed(time.Now().UTC().UnixNano()) ^ ```
1 parent 027d6b6 commit 80fb516

File tree

7 files changed

+25
-19
lines changed

7 files changed

+25
-19
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
kind: NOTES
2+
body: 'all: This Go module has been updated to Go 1.20 per the [Go support
3+
policy](https://go.dev/doc/devel/release#policy). It is recommended to review
4+
the [Go 1.20 release notes](https://go.dev/doc/go1.20) before upgrading. Any
5+
consumers building on earlier Go versions may experience errors.'
6+
time: 2023-09-06T05:58:49.879435-04:00
7+
custom:
8+
Issue: "1245"

.github/workflows/ci-go.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
runs-on: ubuntu-latest
4949
strategy:
5050
matrix:
51-
go-version: [ '1.20', '1.19' ]
51+
go-version: [ '1.21', '1.20' ]
5252
steps:
5353
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
5454
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ When running provider tests, Terraform 0.12.26 or later is needed for version 2.
1818

1919
This project follows the [support policy](https://golang.org/doc/devel/release.html#policy) of Go as its support policy. The two latest major releases of Go are supported by the project.
2020

21-
Currently, that means Go **1.19** or later must be used when including this project as a dependency.
21+
Currently, that means Go **1.20** or later must be used when including this project as a dependency.
2222

2323
## Getting Started
2424

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/hashicorp/terraform-plugin-sdk/v2
22

3-
go 1.19
3+
go 1.20
44

55
require (
66
github.com/google/go-cmp v0.5.9

helper/acctest/random.go

-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ import (
2020
"golang.org/x/crypto/ssh"
2121
)
2222

23-
func init() {
24-
rand.Seed(time.Now().UTC().UnixNano())
25-
}
26-
2723
// Helpers for generating random tidbits for use in identifiers to prevent
2824
// collisions in acceptance tests.
2925

tools/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module tools
22

3-
go 1.19
3+
go 1.20
44

55
require github.com/hashicorp/copywrite v0.16.4
66

website/docs/plugin/sdkv2/testing/acceptance-tests/index.mdx

+13-11
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Create a [GitHub Actions workflow](https://docs.github.com/en/actions/using-work
142142

143143
Use the [`matrix`](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix) strategy for more advanced configuration, such as running acceptance testing against multiple Terraform CLI versions.
144144

145-
The following example workflow runs acceptance testing for the provider using the latest patch versions of Go 1.19 and Terraform CLI 1.3:
145+
The following example workflow runs acceptance testing for the provider using the latest patch versions of Go defined in the `go.mod` file and Terraform CLI 1.5:
146146

147147
```yaml
148148
name: Terraform Provider Tests
@@ -163,12 +163,12 @@ jobs:
163163
runs-on: ubuntu-latest
164164
steps:
165165
- uses: actions/checkout@v3
166-
- uses: actions/setup-go@v3
166+
- uses: actions/setup-go@v4
167167
with:
168-
go-version: '1.19'
168+
go-version-file: 'go.mod'
169169
- uses: hashicorp/setup-terraform@v2
170170
with:
171-
terraform_version: '1.3.*'
171+
terraform_version: '1.5.*'
172172
terraform_wrapper: false
173173
- run: go test -v -cover ./...
174174
env:
@@ -178,14 +178,14 @@ jobs:
178178
runs-on: ubuntu-latest
179179
steps:
180180
- uses: actions/checkout@v3
181-
- uses: actions/setup-go@v3
181+
- uses: actions/setup-go@v4
182182
with:
183-
go-version: '1.19'
183+
go-version-file: 'go.mod'
184184
- run: go test -v -cover ./...
185185
```
186186
187187
188-
The following example workflow runs acceptance testing for the provider using the latest patch versions of Go 1.19 and Terraform CLI 0.12 through 1.3:
188+
The following example workflow runs acceptance testing for the provider using the latest patch versions of Go defined in the `go.mod` file and Terraform CLI 0.12 through 1.5:
189189

190190
```yaml
191191
name: Terraform Provider Tests
@@ -216,11 +216,13 @@ jobs:
216216
- '1.1.*'
217217
- '1.2.*'
218218
- '1.3.*'
219+
- '1.4.*'
220+
- '1.5.*'
219221
steps:
220222
- uses: actions/checkout@v3
221-
- uses: actions/setup-go@v3
223+
- uses: actions/setup-go@v4
222224
with:
223-
go-version: '1.19'
225+
go-version-file: 'go.mod'
224226
- uses: hashicorp/setup-terraform@v2
225227
with:
226228
terraform_version: ${{ matrix.terraform-version }}
@@ -233,9 +235,9 @@ jobs:
233235
runs-on: ubuntu-latest
234236
steps:
235237
- uses: actions/checkout@v3
236-
- uses: actions/setup-go@v3
238+
- uses: actions/setup-go@v4
237239
with:
238-
go-version: '1.19'
240+
go-version-file: 'go.mod'
239241
- run: go test -v -cover ./...
240242
```
241243

0 commit comments

Comments
 (0)