diff --git a/CHANGELOG.md b/CHANGELOG.md index aacf495..06b7394 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt - Changed underlying cobra command setup to return errors instead of calling `os.Exit` directly to enable simpler testing. ([454](https://github.com/cucumber/godog/pull/454) - [mxygem]) - Remove use of deprecated methods from `_examples`. ([460](https://github.com/cucumber/godog/pull/460) - [ricardogarfe]) +### Fixed + +- Support for go1.18 in `godog` cli mode ([466](https://github.com/cucumber/godog/pull/466) - [vearutop]) + ## [v0.12.4] ### Added diff --git a/internal/builder/builder.go b/internal/builder/builder.go index 1514739..8abdb1e 100644 --- a/internal/builder/builder.go +++ b/internal/builder/builder.go @@ -205,6 +205,10 @@ func Build(bin string) error { "-complete", } + if err := filterImportCfg(compilerCfg); err != nil { + return err + } + args = append(args, "-pack", testmain) cmd := exec.Command(compiler, args...) cmd.Env = os.Environ() @@ -234,6 +238,27 @@ func Build(bin string) error { return nil } +// filterImportCfg strips unsupported lines from imports configuration. +func filterImportCfg(path string) error { + orig, err := os.ReadFile(path) + if err != nil { + return fmt.Errorf("failed to read %s: %w", path, err) + } + + res := "" + for _, l := range strings.Split(string(orig), "\n") { + if !strings.HasPrefix(l, "modinfo") { + res += l + "\n" + } + } + err = ioutil.WriteFile(path, []byte(res), 0600) + if err != nil { + return fmt.Errorf("failed to write %s: %w", path, err) + } + + return nil +} + func maybeVendoredGodog() *build.Package { dir, err := filepath.Abs(".") if err != nil {