Go generate location

In order to be better organised and to improve code readability, I want to propose we move //go:generate code for mocks, into package_test.go. With the new mock unit tests being introduced successfully, we have a tendency to scatter the mocking go generation directives in every location possible. I think if we can stick them just in one place, it would make it so much easier to try and locate them. As they are testing related, it would make sense to move them to a testing file and a package_test.go is required for all our test suites at the moment, so it would make sense to go there?

Sounds reasonable too me.
Afaict you already started doing so in some related Patches.
Could you link one here with the respective structure for future references?

Package example https://github.com/juju/juju/blob/develop/state/migrations/package_test.go

1 Like