Skip to content

x/website/_content/ref: clarify documentation of go work use -r #68245

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

Closed
eliben opened this issue Jun 28, 2024 · 7 comments
Closed

x/website/_content/ref: clarify documentation of go work use -r #68245

eliben opened this issue Jun 28, 2024 · 7 comments
Assignees
Labels
Documentation Issues describing a change to documentation.
Milestone

Comments

@eliben
Copy link
Member

eliben commented Jun 28, 2024

Go version

any

Output of go env in your module/workspace:

n/a

What did you do?

The documentation at https://go.dev/ref/mod#go-work-use currently says:

The -r flag searches recursively for modules in the argument directories, and the use command operates as if each of the directories were specified as arguments: namely, use directives will be added for directories that exist, and removed for directories that do not exist.

Which can be taken as "the command will remove directories from the go.work file that weren't found in the recursive tree under the arguments passed to -r"

What did you see happen?

n/a

What did you expect to see?

n/a

@eliben eliben added the Documentation Issues describing a change to documentation. label Jun 28, 2024
@seankhliao seankhliao changed the title doc: clarify documentation of go work use -r x/website/_content/ref: clarify documentation of go work use -r Jun 29, 2024
@gopherbot gopherbot added this to the Unreleased milestone Jun 29, 2024
@matloob
Copy link
Contributor

matloob commented Jul 1, 2024

Okay, so reading "use directives will be added for directories that exist, and removed for directories that do not exist", the subject for both "added" and "removed" seems to me to clearly be "use directives" rather than "directories".

Would "use directives will be added for directories that exist, and they will be removed for directories that do not exist" be more clear?

Or maybe "use directives will be added for directories that exist, and use directives will be removed for directories that do not exist"? It's clunky but it's harder to misinterpret.

@eliben
Copy link
Member Author

eliben commented Jul 1, 2024

I think the mix-up may be on my end; I did not interpret it as "the go tool will remove the actual directories". I was thinking of this scenario:

Suppose I already have a go.work file with a bunch of existing directories in it. Now I want to add some new directories - not related to the existing ones - so I call go work use -r <some-tree>. IIUC, this means that for any directory not in <some-tree>, go work will remove its mention from the go.work file; this is the documented behavior. If the documentation is accurate here, perhaps one just has to be more careful with using the -r mode.

@matloob
Copy link
Contributor

matloob commented Jul 1, 2024

Oh I see. The behavior is that only directories that would be under the tree specified with -r and which do not exist would be removed.

I'm not sure how to rephrase it without making it more awkward. Maybe we can remove the last part of the sentence entirely? "The -r flag searches recursively for modules in the argument directories, and the use command operates as if each of the directories were specified as arguments."

Or maybe "The -r flag searches recursively for modules in the argument directories, and the use command operates as if each of the directories were specified as arguments: namely, use directives will be added for directories that exist, and removed for paths that are under the argument directories but do not exist."

@eliben
Copy link
Member Author

eliben commented Jul 1, 2024

The shorter "The -r flag searches recursively for modules in the argument directories, and the use command operates as if each of the directories were specified as arguments" seems better to me - thanks!

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/595536 mentions this issue: cmd/go/internal/workcmd: remove a potentially confusing statement

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/595997 mentions this issue: _content/ref: remove potentially confusing statement in go work use doc

gopherbot pushed a commit that referenced this issue Jul 1, 2024
A statement in the go work use docs that was meant to clarify that go
work use would clean up use statements where the directories did not
exist ended up causing confusion.

Remove that statement for now. We might want to add something back in
the future.

For #68245

Change-Id: I7f6646b5dd05c18aa15e0e54f2816753f318404e
Reviewed-on: https://go-review.googlesource.com/c/go/+/595536
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Eli Bendersky <[email protected]>
Mchnan pushed a commit to Mchnan/go-sylixos that referenced this issue Jul 9, 2024
A statement in the go work use docs that was meant to clarify that go
work use would clean up use statements where the directories did not
exist ended up causing confusion.

Remove that statement for now. We might want to add something back in
the future.

For golang#68245

Change-Id: I7f6646b5dd05c18aa15e0e54f2816753f318404e
Reviewed-on: https://go-review.googlesource.com/c/go/+/595536
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Eli Bendersky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues describing a change to documentation.
Projects
None yet
Development

No branches or pull requests

4 participants