Commit Graph

12 Commits (suite-faster-methodFilter)

Author SHA1 Message Date
Olivier Mengué 5ca0755b51 codegen: use standard header for generated files
Use the standard header in generated Go sources.
See https://go.dev/s/generatedcode.
2023-07-02 21:06:15 +02:00
Matt Gorzka e72b029e2a new regex 2020-05-14 20:01:26 +10:00
Leigh McCulloch 59bec1f2ff Get the modules aware importer via the function that was available in Go 1.11 and earlier 2019-12-09 10:12:49 -07:00
Leigh McCulloch 711f4df360 Fix codegen for Go Modules
Fix two issues with codegen that cause it not to work with Go Modules.

1. When parsing the code files the package SrcRoot and ImportPath were
being joined which assumes the package is hosted inside a GOPATH src
directory. Using those two fields is unnecessary because a package also
knows what directory it lives in, which is in the Dir field. This change
switches to using the Dir field.

2. When checking the types in the source files the default importer is
being used. Unfortunately the default importer has not been updated to
work with Go Modules and it only looks in the GOPATH for imports.
Luckily the Go team were convinced to backport some logic from the newer
go/packages package to go/build, and we can make use of the go/build
importer which supports Go Modules. One downside of using the go/build
importer is it is said to be slow. For this size project though it's I
don't think it's a problem.

In the future codegen should be rewritten to use go/packages once it is
included in the stdlib. go/packages currently lives at
golang.org/x/tools/go/packages. Once it is in the stdlib I believe it
will replace go/build.

Both fixes are compatible with Go 1.13, Go 1.12, Go 1.11, Go 1.10.

I've also updated the TravisCI config to run go generate, and to add the
newer versions of Go to demonstrate that this works on all versions of
Go.
2019-12-09 10:12:49 -07:00
Ernesto Jiménez c7668ea997 Fixes #339 - Add `assertion`f assertions like Errorf and Equalf 2017-05-29 12:56:43 +01:00
Nick Miyake 13b9dd4e30 Fix typos in comments in _codegen/main.go 2016-11-19 22:28:54 -08:00
Ernesto Jiménez 4b9bfb8845 run go/format on generated code 2016-09-25 23:03:55 +01:00
Ernesto Jiménez 1661650f98 Fix most golint warnings 2016-01-09 19:30:22 +01:00
Ernesto Jiménez 5eeedba61e Fix docs for forwarded assertions 2016-01-07 18:25:18 +01:00
Ernesto Jiménez 4682b3695d Refactor _codegen code 2016-01-07 17:44:02 +01:00
Ernesto Jiménez 7cb9aa9471 Save file once everything succeeds 2015-11-06 17:35:10 +00:00
Ernesto Jiménez efd1b850c1 First version of code generation 2015-11-05 23:08:36 +00:00