Skip to content

Commit

Permalink
Fix support for go1.18 (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop committed Mar 26, 2022
1 parent 5efecba commit 6f877d6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions internal/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 6f877d6

Please sign in to comment.