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

proposal: cmd/go: use go.mod file paths in workspaces #48259

Closed
matloob opened this issue Sep 8, 2021 · 7 comments
Closed

proposal: cmd/go: use go.mod file paths in workspaces #48259

matloob opened this issue Sep 8, 2021 · 7 comments
Labels
Projects
Milestone

Comments

@matloob
Copy link
Contributor

@matloob matloob commented Sep 8, 2021

This issue proposes an amendment to the Workspace proposal (#45713) to use go.mod file paths rather than directory paths in the directory directive, perhaps renaming the directive to use. It was originally suggested by @ianthehat in an issue comment:

Now this proposal is accepted, I would like to suggest some minor changes.

I think that we should change it from listing directories (and implying the go.mod file in that directory) to explicitly listing the mod file.
I think this would remove some of the confusion about exactly what it means to refer to a directory, and would also allow us to add directories with one of the meanings people have asked for in the future if we wanted to.
The cost is negligible, basically existing lines would just need /go.mod appended to the end, and for the most part those lines are written by a tool anyway.
This approach would also increase the flexibility of the system by allowing the go.work file to refer to module files not called go.mod. The go command already allows you to use this files in normal module mode, the two uses I know the most about are go.tools.mod and gopls.mod, but there are other uses as well. This would allow you for instance to have a tools.work file that referred to the go.tools.mod files instead of the go.mod files.
If we did this, we would also need to change the name of the directive (from directory). I don't really mind what to, I was thinking something like use or include, but suggestions are welcome.
The end result would be (using the same example as the proposal)

go 1.18

use (
    ./baz/go.mod // foo.org/bar/baz
    ./tools/go.mod // golang.org/x/tools
)

replace golang.org/x/net => example.com/fork/net v1.4.5

cc @bcmills @jayconrod

@gopherbot gopherbot added this to the Proposal milestone Sep 8, 2021
@matloob
Copy link
Contributor Author

@matloob matloob commented Sep 8, 2021

Personally I could go either way on this proposal, but I wanted to move this out into its own issue so we could have the discussion on a separate issue.

@seankhliao seankhliao changed the title Proposal: use go.mod file paths in workspaces proposal: use go.mod file paths in workspaces Sep 8, 2021
@heschi
Copy link
Contributor

@heschi heschi commented Sep 9, 2021

If the file isn't named go.mod, how would the module root be determined?

@bcmills
Copy link
Member

@bcmills bcmills commented Sep 9, 2021

@heschi, I would assume one of two behaviors:

  1. Files not named go.mod are “packageless modules”, and don't inhabit any directory unless they are colocated with an actual go.mod file that is itself not in the workspace, or
  2. Files not named go.mod are the roots of the modules in their respective directories.

I think (2) would get confusing, though. (Packages in local directories would shift across module boundaries depending on the go.work configuration.)

So that leaves (1). But is even that too complicated?

@heschi
Copy link
Contributor

@heschi heschi commented Sep 9, 2021

I suppose the use directive could take two parameters, the module root and the mod file. But in the absence of concrete use cases it's hard for me to evaluate if that's a good idea.

@ianlancetaylor ianlancetaylor added this to Incoming in Proposals Sep 15, 2021
@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
@rsc rsc changed the title proposal: use go.mod file paths in workspaces proposal: cmd/go: use go.mod file paths in workspaces Oct 6, 2021
@matloob
Copy link
Contributor Author

@matloob matloob commented Oct 19, 2021

We're going to retract this proposal. We haven't gotten consensus on it and it's too late for the discussion to yield anything before the freeze.

@matloob matloob closed this Oct 19, 2021
@rsc rsc moved this from Active to Declined in Proposals Oct 20, 2021
@rsc
Copy link
Contributor

@rsc rsc commented Oct 20, 2021

This proposal has been declined as retracted.
— rsc for the proposal review group

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Proposals
Declined
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants