-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…130) As of Go 1.18 [1] the debug.ReadBuildInfo [2] function does not work for Mage executables anymore because the way how module information is stored changed. Therefore the fields of the returned debug.Module [3] type only has zero values, including the module path. The debug.Module.Version [4] field has a default value [5] (`(devel)`) which is not Semver compatible and causes the parsing to fail. The change in Go 1.18 [9] also came with the new `debug/buildinfo` package [10] which allows to read the information from compiled binaries while the `runtime/debug.ReadBuildInfo` function returns information from within the running binary. Both are not suitable anymore which is also described in the Go 1.18 `version` command release notes: "The underlying data format of the embedded build information can change with new `go` releases, so an older version of `go` may not handle the build information produced with a newer version of `go`. To read the version information from a binary built with `go` 1.18, use the `go` version command and the `debug/buildinfo` package from `go` 1.18+." To get the required module information that was previously provided by the runtime/debug [6] package the official golang.org/x/mod/modfile [7] package is now used instead that provides the implementation for a parser and formatter for `go.mod` files [8] [^1]. This allows to safely get the module path without the need to depend on runtime/dynamic logic that might change in future Go versions. Note that this change also increased the minimum Go version from `1.17` to `1.19`! [1]: golang/go@9cec77ac#diff-abdadaf0d85a2e6c8e45da716909b2697d830b0c75149b9e35accda9c38622bdR2234 [2]: https://pkg.go.dev/runtime/debug@go1.18#ReadBuildInfo [3]: https://pkg.go.dev/runtime/debug#Module [4]: https://github.com/golang/go/blob/9cec77ac/src/runtime/debug/mod.go#L52 [5]: https://github.com/golang/go/blob/122a22e0e9eba7fe712030d429fc4bcf6f447f5e/src/cmd/go/internal/load/pkg.go#L2288 [6]: https://pkg.go.dev/runtime/debug@go1.18.8 [7]: https://pkg.go.dev/golang.org/x/mod/modfile [8]: https://pkg.go.dev/cmd/go#hdr-The_go_mod_file [9]: https://tip.golang.org/doc/go1.18#go-version [10]: https://tip.golang.org/doc/go1.18#debug/buildinfo [^1]: https://go.dev/ref/mod#go-mod-file GH-129
- Loading branch information
Showing
5 changed files
with
73 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters