Skip to content

Commit

Permalink
all: Update Go Module to Go 1.20 (#1246)
Browse files Browse the repository at this point in the history
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())
	^
```
  • Loading branch information
bflad authored Sep 6, 2023
1 parent 027d6b6 commit 80fb516
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 19 deletions.
8 changes: 8 additions & 0 deletions .changes/unreleased/NOTES-20230906-055849.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
kind: NOTES
body: 'all: This Go module has been updated to Go 1.20 per the [Go support
policy](https://go.dev/doc/devel/release#policy). It is recommended to review
the [Go 1.20 release notes](https://go.dev/doc/go1.20) before upgrading. Any
consumers building on earlier Go versions may experience errors.'
time: 2023-09-06T05:58:49.879435-04:00
custom:
Issue: "1245"
2 changes: 1 addition & 1 deletion .github/workflows/ci-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.20', '1.19' ]
go-version: [ '1.21', '1.20' ]
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ When running provider tests, Terraform 0.12.26 or later is needed for version 2.

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.

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

## Getting Started

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/hashicorp/terraform-plugin-sdk/v2

go 1.19
go 1.20

require (
github.com/google/go-cmp v0.5.9
Expand Down
4 changes: 0 additions & 4 deletions helper/acctest/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ import (
"golang.org/x/crypto/ssh"
)

func init() {
rand.Seed(time.Now().UTC().UnixNano())
}

// Helpers for generating random tidbits for use in identifiers to prevent
// collisions in acceptance tests.

Expand Down
2 changes: 1 addition & 1 deletion tools/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module tools

go 1.19
go 1.20

require github.com/hashicorp/copywrite v0.16.4

Expand Down
24 changes: 13 additions & 11 deletions website/docs/plugin/sdkv2/testing/acceptance-tests/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Create a [GitHub Actions workflow](https://docs.github.com/en/actions/using-work

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.

The following example workflow runs acceptance testing for the provider using the latest patch versions of Go 1.19 and Terraform CLI 1.3:
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:

```yaml
name: Terraform Provider Tests
Expand All @@ -163,12 +163,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version-file: 'go.mod'
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: '1.3.*'
terraform_version: '1.5.*'
terraform_wrapper: false
- run: go test -v -cover ./...
env:
Expand All @@ -178,14 +178,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version-file: 'go.mod'
- run: go test -v -cover ./...
```
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:
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:

```yaml
name: Terraform Provider Tests
Expand Down Expand Up @@ -216,11 +216,13 @@ jobs:
- '1.1.*'
- '1.2.*'
- '1.3.*'
- '1.4.*'
- '1.5.*'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version-file: 'go.mod'
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ matrix.terraform-version }}
Expand All @@ -233,9 +235,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version-file: 'go.mod'
- run: go test -v -cover ./...
```

Expand Down

0 comments on commit 80fb516

Please sign in to comment.