Skip to content

Commit dc08095

Browse files
committed
_content/ref: update the modules reference for GOWORK
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 <[email protected]> Run-TryBot: Michael Matloob <[email protected]> Reviewed-by: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Beth Brown <[email protected]>
1 parent 9274736 commit dc08095

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

_content/doc/tutorial/workspaces.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ add a new function to the `stringutil` package that we can use instead of `Rever
190190
191191
We'll add a new function to uppercase a string to the `golang.org/x/example/stringutil` package.
192192
193-
Add a new folder to the `workspace/example/stringutil` directory containing the following contents:
193+
Create a new file named `toupper.go` in the `workspace/example/stringutil` directory containing the following contents:
194194
195195
```
196196
package stringutil
@@ -230,7 +230,7 @@ add a new function to the `stringutil` package that we can use instead of `Rever
230230
From the workspace directory, run
231231
232232
```
233-
$ go run example/hello
233+
$ go run example.com/hello
234234
HELLO
235235
```
236236

_content/ref/mod.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,14 +1088,17 @@ operate on the set of modules determined by the current workspace.
10881088
and `go get` always operate on a single main module.
10891089

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

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

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

14551453
### Vendoring {#vendoring}
14561454

@@ -4325,6 +4323,20 @@ GOSUMDB="sum.golang.org+&lt;publickey&gt; https://sum.golang.org"
43254323
</p>
43264324
</td>
43274325
</tr>
4326+
<tr>
4327+
<td><code>GOWORK</code></td>
4328+
<td>
4329+
<p>
4330+
The `GOWORK` environment variable instructs the `go` command to enter workspace
4331+
mode using the provided [`go.work` file](#go-work-file) to define the workspace.
4332+
If `GOWORK` is set to `off` workspace mode is disabled. This can be used to run
4333+
the `go` command in single module mode: for example, `GOWORK=off go build .` builds
4334+
the `.` package in single-module mode.`If `GOWORK` is empty, the
4335+
`go` command will search for a `go.work` file as described in the [Workspaces](#workspaces)
4336+
section.
4337+
</p>
4338+
</td>
4339+
</tr>
43284340
</tbody>
43294341
</table>
43304342

0 commit comments

Comments
 (0)