Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Goagen Generates Controller Code That Fails to Compile Under Go 1.11 #1850

Closed
kmacmcfarlane opened this issue Aug 29, 2018 · 3 comments
Closed

Comments

@kmacmcfarlane
Copy link
Contributor

Expected Behavior

Goagen should produce test helpers that compile.

Actual Behavior

Under Go 1.11, the resp variable is no longer considered 'used' by the function closure respSetter in the generated code.

It's part of a change of behavior of go vet under 1.11. Here's more info (under the "Test" heading": https://tip.golang.org/doc/go1.11#test

Here's an example excerpt of the generated code that no longer compiles I'm referencing:

...
func ShowHealthCheckOK(t goatest.TInterface, ctx context.Context, service *goa.Service, ctrl app.HealthCheckController) (http.ResponseWriter, *app.APIHealthcheck) {
	// Setup service
	var (
		logBuf bytes.Buffer
		resp   interface{}

		respSetter goatest.ResponseSetterFunc = func(r interface{}) { resp = r }
	)
...

Steps to Reproduce the Problem (including complete and simple design if relevant)

  1. Upgrade to Go 1.11
  2. Generate a controller with goagen
  3. Use test helper class in a unit test
  4. Run test

When the app/foobar_controller_test.go files are being compiled by go test, vet fails the compilation.

app/test/auth0_testing.go:1098:3: resp declared but not used
app/test/auth0_testing.go:1021:3: resp declared but not used
app/test/auth0_testing.go:626:3: resp declared but not used
app/test/auth0_testing.go:317:3: resp declared but not used
app/test/auth0_testing.go:222:3: resp declared but not used
app/test/auth0_testing.go:127:3: resp declared but not used
app/test/auth0_testing.go:32:3: resp declared but not used

Specifications

  • goa Version: (goagen) 1.3.1
  • Platform (Linux/Windows etc.): Linux
@raphael
Copy link
Member

raphael commented Aug 29, 2018

Thank you for the report! Is that something you might be able to take a look at?

@thundercat1
Copy link

I believe I was having the same problem, but I was able to resolve it by updating to latest version of goa and regenerating.
#1548

@raphael
Copy link
Member

raphael commented Sep 27, 2018

Thank you for spotting that @thundercat1 !
Duplicate of #1548

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants