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

Open
bcmills opened this issue Jun 14, 2019 · 3 comments
Labels
FeatureRequest help wanted modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@bcmills
Copy link
Contributor

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

@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. FeatureRequest labels Jun 14, 2019
@gopherbot gopherbot added this to the Unreleased milestone Jun 14, 2019
@bcmills
Copy link
Contributor Author

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!

@dmitshur
Copy link
Contributor

Also /cc @toothrot.

@toothrot
Copy link
Contributor

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
Labels
FeatureRequest help wanted modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants