hashicorp / go-multierror

A Go (golang) package for representing a list of errors as a single error.
Mozilla Public License 2.0
2.3k stars 123 forks source link

Go version missing from documentations. #37

Closed MonishAkram closed 3 years ago

MonishAkram commented 4 years ago

I'm using golang v1.12 but this package is not supported because of errors.Is and errors.As functions which are not present in v1.12 and was added in v1.13. And there is no version requirement mentioned in the documentation. for this package

IngCr3at1on commented 4 years ago

Counterpoint: the go team themselves doesn't even support farther back than 2 versions, 1.14 was released in February which means even at the time of writing this issue 1.12 was not officially supported by the go team; is there a reason this package should support more than what is officially supported (assuming no, there is no reason to assume anything before 1.13 would work, with the release of 1.15 in August that would actually be 1.14 as the earliest officially supported version of Go)?

webmaster777 commented 3 years ago

Having random errors like

> go get -u github.com/mattermost/mmctl
# github.com/mattermost/mmctl/vendor/github.com/hashicorp/go-multierror
go/src/github.com/mattermost/mmctl/vendor/github.com/hashicorp/go-multierror/multierror.go:112:9: undefined: errors.As
go/src/github.com/mattermost/mmctl/vendor/github.com/hashicorp/go-multierror/multierror.go:117:9: undefined: errors.Is

How does one tell I need to upgrade go? I have no idea how package mangagement works in Go, but I'm used to version constraint explanations in other langs/package managers (js/php) etc.

mwhooker commented 3 years ago

Hmm, yeah this should be documented. FWIW, v1.0.0 supports go < 1.13, while v1.1.0 requires go 1.13.

I also notice that in the go.mod file, the line go 1.14. This indicates that the module requires go 1.14. Infact, when I build this using go 1.12, I get the following error:

root@f97226dc12fd:/go/src/github.com/mwhooker/testmultierror# go run main.go
go: finding github.com/hashicorp/go-multierror v1.1.0
go: downloading github.com/hashicorp/go-multierror v1.1.0
go: extracting github.com/hashicorp/go-multierror v1.1.0
go: finding github.com/hashicorp/errwrap v1.0.0
go: downloading github.com/hashicorp/errwrap v1.0.0
go: extracting github.com/hashicorp/errwrap v1.0.0
# github.com/hashicorp/go-multierror
/go/pkg/mod/github.com/hashicorp/go-multierror@v1.1.0/multierror.go:112:9: undefined: errors.As
/go/pkg/mod/github.com/hashicorp/go-multierror@v1.1.0/multierror.go:117:9: undefined: errors.Is
**note: module requires Go 1.14**

(emphasis mine).

Of course, because there's this ticket, this doesn't seem sufficient, but the requirement does exist. I would be happy to review any PRs that came in for documenting the required go version

Edit: ahh, I think the behavior I see above (where it says the module requires go 1.14) was added in a later version of go than you might be using @webmaster777, so you didn't see the message. I think we should still document it, but my advice would be to use a version of go at most one "major" version out of date. To quote from the go release page:

Each major Go release is supported until there are two newer major releases. For example, Go 1.5 was supported until the Go 1.7 release, and Go 1.6 was supported until the Go 1.8 release.

ggirtsou commented 3 years ago

Fixed after upgrading to Go 1.15. I was importing spf13/viper and golang-migrate packages in my Go vendor directory (they require different version of go-multierror).