Skip to content

Fix error finding 'Go'

Matthew Hughes requested to merge fix-go-moving-around into main
  • Stop using runtime.GOROOT to find Go

    Just exec "go" directly. From the docs:

    It uses the GOROOT environment variable, if set at process start, or else the root used during the Go build.

    Since most environments I've seen don't set GOROOT the value is taken from build time, this causes issues when:

    • Go isn't rooted on your system in the same place as on my system
    • You build and run this application under different versions of Go and GOROOT is set depending on the version, e.g. /opt/hostedtoolcache/go/1.22.0

    [1] https://pkg.go.dev/runtime#GOROOT

  • Simplify testadata setup

    Move testdata closer to where it's tested and remove unnecessary path finding logic since, per the docs[1]:

    When 'go test' runs a test binary, it does so from within the corresponding package's source code directory.

    So we can just find testdata relative to where the tests are being run.

    [1] https://pkg.go.dev/cmd/go#hdr-Testing_flags

Merge request reports