Skip to content

Commit 6f877d6

Browse files
authored
Fix support for go1.18 (#466)
1 parent 5efecba commit 6f877d6

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
1515
- 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])
1616
- Remove use of deprecated methods from `_examples`. ([460](https://github.com/cucumber/godog/pull/460) - [ricardogarfe])
1717

18+
### Fixed
19+
20+
- Support for go1.18 in `godog` cli mode ([466](https://github.com/cucumber/godog/pull/466) - [vearutop])
21+
1822
## [v0.12.4]
1923

2024
### Added

internal/builder/builder.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ func Build(bin string) error {
205205
"-complete",
206206
}
207207

208+
if err := filterImportCfg(compilerCfg); err != nil {
209+
return err
210+
}
211+
208212
args = append(args, "-pack", testmain)
209213
cmd := exec.Command(compiler, args...)
210214
cmd.Env = os.Environ()
@@ -234,6 +238,27 @@ func Build(bin string) error {
234238
return nil
235239
}
236240

241+
// filterImportCfg strips unsupported lines from imports configuration.
242+
func filterImportCfg(path string) error {
243+
orig, err := os.ReadFile(path)
244+
if err != nil {
245+
return fmt.Errorf("failed to read %s: %w", path, err)
246+
}
247+
248+
res := ""
249+
for _, l := range strings.Split(string(orig), "\n") {
250+
if !strings.HasPrefix(l, "modinfo") {
251+
res += l + "\n"
252+
}
253+
}
254+
err = ioutil.WriteFile(path, []byte(res), 0600)
255+
if err != nil {
256+
return fmt.Errorf("failed to write %s: %w", path, err)
257+
}
258+
259+
return nil
260+
}
261+
237262
func maybeVendoredGodog() *build.Package {
238263
dir, err := filepath.Abs(".")
239264
if err != nil {

0 commit comments

Comments
 (0)