@@ -1088,14 +1088,17 @@ operate on the set of modules determined by the current workspace.
1088
1088
and ` go get ` always operate on a single main module.
1089
1089
1090
1090
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
1092
1092
in a single-module context. If it is empty or not provided, the command
1093
1093
will search the current working directory, and then successive parent directories,
1094
1094
for a file ` go.work ` . If a file is found, the command will operate in the
1095
1095
workspace it defines; otherwise, the workspace will include only the module
1096
1096
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.
1099
1102
1100
1103
### ` go.work ` files {#go-work-file}
1101
1104
@@ -1446,11 +1449,6 @@ commands accept the following flags, common to all module commands.
1446
1449
` -modfile ` is specified, an alternate ` go.sum ` file is also used: its path is
1447
1450
derived from the ` -modfile ` flag by trimming the ` .mod ` extension and
1448
1451
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.
1454
1452
1455
1453
### Vendoring {#vendoring}
1456
1454
@@ -4325,6 +4323,20 @@ GOSUMDB="sum.golang.org+<publickey> https://sum.golang.org"
4325
4323
</p>
4326
4324
</td>
4327
4325
</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>
4328
4340
</tbody >
4329
4341
</table >
4330
4342
0 commit comments