Skip to content

Commit

Permalink
_content/ref: update the modules reference for GOWORK
Browse files Browse the repository at this point in the history
The -workfile flag's function has been absorbed by the GOWORK
environment variable. Update the workspaces reference to reflect that.
Also fix an error in the workspaces tutorial.

For golang/go#45713

Change-Id: Id8dc8bb8dc6458d03d7b947ec78d84263d9689e1
Reviewed-on: https://go-review.googlesource.com/c/website/+/393360
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Beth Brown <ecbrown@google.com>
  • Loading branch information
matloob committed Mar 21, 2022
1 parent 9274736 commit dc08095
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
4 changes: 2 additions & 2 deletions _content/doc/tutorial/workspaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ add a new function to the `stringutil` package that we can use instead of `Rever

We'll add a new function to uppercase a string to the `golang.org/x/example/stringutil` package.

Add a new folder to the `workspace/example/stringutil` directory containing the following contents:
Create a new file named `toupper.go` in the `workspace/example/stringutil` directory containing the following contents:

```
package stringutil
Expand Down Expand Up @@ -230,7 +230,7 @@ add a new function to the `stringutil` package that we can use instead of `Rever
From the workspace directory, run

```
$ go run example/hello
$ go run example.com/hello
HELLO
```

Expand Down
28 changes: 20 additions & 8 deletions _content/ref/mod.md
Original file line number Diff line number Diff line change
Expand Up @@ -1088,14 +1088,17 @@ operate on the set of modules determined by the current workspace.
and `go get` always operate on a single main module.

A command determines whether it is in a workspace context by first examining
the `-workfile` flag. If `-workfile` is set to `off`, the command will be
the `GOWORK` environment variable. If `GOWORK` is set to `off`, the command will be
in a single-module context. If it is empty or not provided, the command
will search the current working directory, and then successive parent directories,
for a file `go.work`. If a file is found, the command will operate in the
workspace it defines; otherwise, the workspace will include only the module
containing the working directory.
If `-workfile` names a path to an existing file that ends in .work,
workspace mode will be enabled. Any other value is an error.
If `GOWORK` names a path to an existing file that ends in .work,
workspace mode will be enabled. Any other value is an error. You can use the
`go env GOWORK` command to determine which `go.work` file the `go` command
is using. `go env gowork` will be empty if the `go` command is not in workspace
mode.

### `go.work` files {#go-work-file}

Expand Down Expand Up @@ -1446,11 +1449,6 @@ commands accept the following flags, common to all module commands.
`-modfile` is specified, an alternate `go.sum` file is also used: its path is
derived from the `-modfile` flag by trimming the `.mod` extension and
appending `.sum`.
* The `-workfile` flag instructs the `go` command to enter workspace mode using the provided
[`go.work` file](#go-work-file) to define the workspace. If `-workfile` is
set to `off` workspace mode is disabled. If `-workfile` is not provided the
`go` command will search for a `go.work` file as described in the
[Workspaces](#workspaces) section.

### Vendoring {#vendoring}

Expand Down Expand Up @@ -4325,6 +4323,20 @@ GOSUMDB="sum.golang.org+&lt;publickey&gt; https://sum.golang.org"
</p>
</td>
</tr>
<tr>
<td><code>GOWORK</code></td>
<td>
<p>
The `GOWORK` environment variable instructs the `go` command to enter workspace
mode using the provided [`go.work` file](#go-work-file) to define the workspace.
If `GOWORK` is set to `off` workspace mode is disabled. This can be used to run
the `go` command in single module mode: for example, `GOWORK=off go build .` builds
the `.` package in single-module mode.`If `GOWORK` is empty, the
`go` command will search for a `go.work` file as described in the [Workspaces](#workspaces)
section.
</p>
</td>
</tr>
</tbody>
</table>

Expand Down

0 comments on commit dc08095

Please sign in to comment.