Skip to content

Commit 0bf0d57

Browse files
seankhliaogopherbot
authored andcommitted
_content/doc/modules: document godebug directive in go.mod
Fixes golang/go#69688 Updates golang/go#56986 Change-Id: I4c55b57d974b434fec74e38034d1ce033204ae12 Reviewed-on: https://go-review.googlesource.com/c/website/+/618115 Reviewed-by: Tim King <[email protected]> Auto-Submit: Tim King <[email protected]> Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
1 parent 211da74 commit 0bf0d57

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

_content/doc/modules/gomod-ref.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,47 @@ Go Modules Reference.
249249
See “[Go toolchains](/doc/toolchain)” for details about how the `toolchain` line
250250
affects Go toolchain selection.
251251
252+
## godebug {#godebug}
253+
254+
Indicates the default [GODEBUG](/doc/godebug) settings to be applied to the main packages of this module.
255+
These override any toolchain defaults, and are overridden by explicit `//go:debug` lines in main packages.
256+
257+
### Syntax {#godebug-syntax}
258+
259+
<pre>godebug <var>debug-key</var>=<var>debug-value</var></pre>
260+
261+
<dl>
262+
<dt>debug-key</dt>
263+
<dd>The name of the setting to be applied.
264+
A list of settings and the versions they were introduced in can be found at [
265+
GODEBUG History](https://go.dev/doc/godebug#history).
266+
</dd>
267+
<dt>debug-value</dt>
268+
<dd>The value provided to the setting.
269+
If not otherwise specified, `0` to disable and `1` to enable the named behavior.</dd>
270+
</dl>
271+
272+
### Examples {#godebug-examples}
273+
274+
* Use the new 1.23 `asynctimerchan=0` behavior:
275+
```
276+
godebug asynctimerchan=0
277+
```
278+
* Use the default GODEBUGs from Go 1.21, but the old `panicnil=1` behavior:
279+
```
280+
godebug (
281+
default=go1.21
282+
panicnil=1
283+
)
284+
```
285+
286+
### Notes {#godebug-notes}
287+
288+
GODEBUG settings only apply for builds of main packages and test binaries in the current module.
289+
They have no effect when a module is used as a dependency.
290+
291+
See “[Go, Backwards Compatibility, and GODEBUG](/doc/godebug)” for details on backwards compatibility.
292+
252293
## require {#require}
253294
254295
Declares a module as a dependency of the current module, specifying the

0 commit comments

Comments
 (0)