Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove github.com/hashicorp/go-multierror Direct Dependency #99

Closed
bflad opened this issue Mar 10, 2023 · 2 comments · Fixed by #181
Closed

Remove github.com/hashicorp/go-multierror Direct Dependency #99

bflad opened this issue Mar 10, 2023 · 2 comments · Fixed by #181
Assignees
Labels
dependencies Pull requests that update a dependency file
Milestone

Comments

@bflad
Copy link
Contributor

bflad commented Mar 10, 2023

terraform-plugin-testing version

v1.1.0

Description

github.com/hashicorp/go-multierror has been HashiCorp's generic "multiple errors in one error" solution well before Go 1.13 introduced error unwrapping. Go 1.20, released recently, now also includes native multiple error functionality via errors.Join(...error). According to this Go module's Go language support policy, it must support Go 1.19 until Go 1.21 is released in the August 2023 timeframe.

There are three usages of go-multierror:

  • helper/resource.ComposeAggregateTestCheckFunc
  • helper/resource.TestComposeAggregateTestCheckFunc
  • (*terraform.State).Validate

Removing github.com/hashicorp/go-multierror would also remove github.com/hashicorp/errwrap -- but it may take a few other dependency changes to fully prune out both these Go modules.

Proposal

These code references can be migrated to collect errors in an []error and then combined with formatting similar to go-multierror or errors.Join(). If nothing has happened for this issue when this Go module updates its minimum Go version to Go 1.20, then go-multierror code can be migrated to errors.Join() instead of manually formatting.

References

@bflad
Copy link
Contributor Author

bflad commented Mar 22, 2023

#63, once merged, will provide an errorshim package we can use to replace usage. 👍

bflad added a commit that referenced this issue Sep 6, 2023
…ndency

Reference: https://pkg.go.dev/errors#Join
Reference: https://pkg.go.dev/math/rand#Seed
Reference: #99
Reference: #180

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())
        ^
```

Fully removing the go-multierror dependency will require some other upstream updates, e.g.

```
# github.com/hashicorp/go-multierror
github.com/hashicorp/terraform-plugin-testing/helper/resource
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema
github.com/hashicorp/go-multierror
```
@bflad bflad self-assigned this Sep 6, 2023
@bflad bflad added this to the v1.6.0 milestone Sep 6, 2023
@bflad bflad added the dependencies Pull requests that update a dependency file label Sep 6, 2023
@bflad bflad closed this as completed in #181 Sep 6, 2023
bflad added a commit that referenced this issue Sep 6, 2023
…ndency (#181)

Reference: https://pkg.go.dev/errors#Join
Reference: https://pkg.go.dev/math/rand#Seed
Reference: #99
Reference: #180

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())
        ^
```

Fully removing the go-multierror dependency will require some other upstream updates, e.g.

```
# github.com/hashicorp/go-multierror
github.com/hashicorp/terraform-plugin-testing/helper/resource
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema
github.com/hashicorp/go-multierror
```
bflad added a commit to hashicorp/terraform-plugin-sdk that referenced this issue Sep 6, 2023
Reference: hashicorp/terraform-plugin-testing#99

Similar to terraform-plugin-testing, now that this Go module is Go 1.20+, we can use native `errors.Join()` functionality for joining multiple errors.

To fully remove the dependency, will need to update some other dependencies as well, e.g.

```
# github.com/hashicorp/go-multierror
github.com/hashicorp/terraform-plugin-sdk/v2/internal/plugintest
github.com/hashicorp/hc-install
github.com/hashicorp/go-multierror
```
bflad added a commit to hashicorp/terraform-plugin-sdk that referenced this issue Sep 6, 2023
)

Reference: hashicorp/terraform-plugin-testing#99

Similar to terraform-plugin-testing, now that this Go module is Go 1.20+, we can use native `errors.Join()` functionality for joining multiple errors.

To fully remove the dependency, will need to update some other dependencies as well, e.g.

```
# github.com/hashicorp/go-multierror
github.com/hashicorp/terraform-plugin-sdk/v2/internal/plugintest
github.com/hashicorp/hc-install
github.com/hashicorp/go-multierror
```
@github-actions
Copy link

github-actions bot commented Oct 7, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
1 participant