diff --git a/go.mod b/go.mod index 8e98046d..184ac3f8 100644 --- a/go.mod +++ b/go.mod @@ -20,6 +20,7 @@ require ( github.com/yuin/gopher-lua v1.1.1 github.com/zclconf/go-cty v1.17.0 go.yaml.in/yaml/v4 v4.0.0-rc.3 + golang.org/x/mod v0.31.0 golang.org/x/net v0.49.0 golang.org/x/text v0.33.0 gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 @@ -33,7 +34,6 @@ require ( github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect - golang.org/x/mod v0.31.0 // indirect golang.org/x/sync v0.19.0 // indirect golang.org/x/sys v0.40.0 // indirect golang.org/x/tools v0.40.0 // indirect diff --git a/go_install_test.go b/go_install_test.go new file mode 100644 index 00000000..0df50ecd --- /dev/null +++ b/go_install_test.go @@ -0,0 +1,24 @@ +package main + +import ( + "io" + "testing" + + "golang.org/x/mod/module" + "golang.org/x/mod/zip" +) + +// TestGoInstallCompatibility ensures the module can be zipped for go install. +// This is an integration test that uses the same zip.CreateFromDir function +// that go install uses internally. If this test fails, go install will fail. +// See: https://github.com/mikefarah/yq/issues/2587 +func TestGoInstallCompatibility(t *testing.T) { + mod := module.Version{ + Path: "github.com/mikefarah/yq/v4", + Version: "v4.0.0", // the actual version doesn't matter for validation + } + + if err := zip.CreateFromDir(io.Discard, mod, "."); err != nil { + t.Fatalf("Module cannot be zipped for go install: %v", err) + } +}