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

cmd/go: add a go work use command #48257

Open
matloob opened this issue Sep 8, 2021 · 8 comments
Open

cmd/go: add a go work use command #48257

matloob opened this issue Sep 8, 2021 · 8 comments

Comments

@matloob
Copy link
Contributor

@matloob matloob commented Sep 8, 2021

This proposal is an amendment of the Go Workspace Proposal (#45713) originally suggested by @jayconrod in a comment on that issue:

I'd like a way to add all modules in a subtree to a workspace using wildcards. Specifically, I'd like go workspace add ./....

  • go workspace use would be a better subcommand name if we end up using that in go.work.
  • I think this would help build a more familiar environment for folks used to working on related projects in GOPATH. I could put a go.work file in $GOPATH/src, then just have one VSCode window for all projects.
  • We've talked about supporting wildcards in go mod initwork and go mod editwork, but that breaks some parallelism with go mod init, which only creates an empty go.mod file, and go mod edit, which only performs low-level syntactic edits without extra processing.

This proposal would add a new go command subcommand, perhaps called go mod addwork (if #48256 is accepted, the new subcommand would be called go work add or go work use).

It would ensure that the go.work command contains modules denoted by the given pattern, removing any matches of the pattern that no longer exist on disk.

cc @bcmills @ianthehat

@gopherbot gopherbot added this to the Proposal milestone Sep 8, 2021
@seankhliao seankhliao changed the title Proposal: cmd/go: add a go mod addwork command proposal: cmd/go: add a go mod addwork command Sep 8, 2021
@bcmills
Copy link
Member

@bcmills bcmills commented Sep 9, 2021

Would there be a corresponding command to remove modules from the workspace? (That could be useful for, say, scripting.)

@ianlancetaylor ianlancetaylor added this to Incoming in Proposals Sep 15, 2021
@matloob
Copy link
Contributor Author

@matloob matloob commented Sep 17, 2021

Modules can still be removed by go mod editwork, and go mod addwork will remove any modules that match the pattern but don't exist on disk.

@rsc
Copy link
Contributor

@rsc rsc commented Oct 6, 2021

This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group

@rsc rsc moved this from Incoming to Active in Proposals Oct 6, 2021
@hyangah
Copy link
Contributor

@hyangah hyangah commented Oct 11, 2021

@rsc Is it possible to review #48256 together at the proposal review meetings? (go mod addwork vs go work add) That proposal is not in the active column yet.

This proposal would add a new go command subcommand, perhaps called go mod addwork (if #48256 is accepted, the new subcommand would be called go work add or go work use).

@rsc
Copy link
Contributor

@rsc rsc commented Oct 12, 2021

@hyangah added to my list for next meeting, thanks. Not sure how I missed that one.

@matloob matloob changed the title proposal: cmd/go: add a go mod addwork command proposal: cmd/go: add a go work use command Oct 12, 2021
@matloob
Copy link
Contributor Author

@matloob matloob commented Oct 12, 2021

In consultation with @jayconrod @rsc and @bcmills, we want to rename this proposed command to go work use (or go mod usework if #48256 isn't accepted). Along with renaming the command, we'd rename the directory to to use. go work use would add a single directory or set of directories stated on the command line and go work use -r would search all subdirectories recursively and add the modules it finds (or remove modules in the go.work file that are contained in the directory but no longer exist).

@rsc rsc moved this from Active to Likely Accept in Proposals Oct 13, 2021
@rsc
Copy link
Contributor

@rsc rsc commented Oct 13, 2021

Based on the discussion above, this proposal seems like a likely accept.
— rsc for the proposal review group

@rsc rsc moved this from Likely Accept to Accepted in Proposals Oct 20, 2021
@rsc
Copy link
Contributor

@rsc rsc commented Oct 20, 2021

No change in consensus, so accepted. 🎉
This issue now tracks the work of implementing the proposal.
— rsc for the proposal review group

@rsc rsc changed the title proposal: cmd/go: add a go work use command cmd/go: add a go work use command Oct 20, 2021
@rsc rsc removed this from the Proposal milestone Oct 20, 2021
@rsc rsc added this to the Backlog milestone Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Proposals
Accepted
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants