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

x/playground: if Imports is checked, run 'go mod tidy' when the Format button is pressed #32614

bcmills opened this issue Jun 14, 2019 · 3 comments


Copy link

@bcmills bcmills commented Jun 14, 2019

CL 177421 added formatting for go.mod files in the Playground.

However, that isn't really enough to result in a reproducible build: as noted in #31944 (comment), unresolved dependencies are re-resolved whenever the cache is invalidated, which is difficult to predict.

One simple fix to add stability would be to have the existing Imports checkbox trigger a go mod tidy after running goimports. That would make the versions in use much clearer in the code and more stable over time, without the need for humans to manually resolve and copy over their go.mod files.

CC @dmitshur @ysmolsky

Copy link
Member Author

@bcmills bcmills commented Jun 14, 2019

This would also make it possible for users to add a go.sum file to their Playground example to show exactly which modules end up being loaded during the build. That seems like a handy bonus feature!

Copy link

@dmitshur dmitshur commented Jun 14, 2019

Also /cc @toothrot.

Copy link

@toothrot toothrot commented Jul 2, 2019

It looks like the current implementation of Format uses the go/format core library instead of the Run approach of running exec.Command.

In order to run go mod tidy, the Format handler may need to act more like Run: writing the files to a temporary space, running a command, then in this case, reading the files back out.

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

Successfully merging a pull request may close this issue.

None yet
4 participants