aboutsummaryrefslogtreecommitdiff
path: root/doc/next/3-tools.md
blob: e73e8a73a39bd90de2e485387a0f7da4106eae33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
## Tools {#tools}

### Go command {#go-command}

Setting the `GOROOT_FINAL` environment variable no longer has an effect
([#62047](/issue/62047)).
Distributions that install the `go` command to a location other than
`$GOROOT/bin/go` should install a symlink instead of relocating
or copying the `go` binary.

<!-- go.dev/issue/34208, CL 563137, CL 586095 -->
The new `go` `env` `-changed` flag causes the command to print only
those settings whose effective value differs from the default value
that would be obtained in an empty environment with no prior uses of the `-w` flag.

<!-- go.dev/issue/27005, CL 585401 -->
The new `go` `mod` `tidy` `-diff` flag causes the command not to modify
the files but instead print the necessary changes as a unified diff.
It exits with a non-zero code if updates are needed.

<!-- go.dev/issue/52792, CL 562775 -->
<!-- TODO: Improve this if needed. -->
The `go` `list` `-m` `-json` command now includes new `Sum` and `GoModSum` fields.
This is similar to the existing behavior of the `go` `mod` `download` `-json` command.

<!-- go.dev/issue/67111 ("cmd/go: add go telemetry subcommand") -->
The new `go` `telemetry` command can be used to view and configure the telemetry collection
mode. Without arguments, it displays the current mode. With `local`, `on`, or `off`, it sets
the collection mode. `go` `env` now lists two values: the `GOTELEMETRY` value, which
contains the telemetry collection mode, and the `GOTELEMETRYDIR` value setting which contains
the directory telemetry data and configuration are written to.

<!-- go.dev/issue/58894 ("all: add opt-in transparent telemetry to Go toolchain") -->
<!-- TODO: document Go 1.23 behavior (from https://go.dev/cl/559199, https://go.dev/cl/559519, https://go.dev/cl/559795, https://go.dev/cl/562715, https://go.dev/cl/562735, https://go.dev/cl/564555, https://go.dev/cl/570679, https://go.dev/cl/570736, https://go.dev/cl/582695, https://go.dev/cl/584276, https://go.dev/cl/585235, https://go.dev/cl/586138) -->

<!-- go.dev/issue/65573 ("cmd/go: separate default GODEBUGs from go language version") -->
<!-- TODO: document Go 1.23 behavior (from https://go.dev/cl/584218, https://go.dev/cl/584300, https://go.dev/cl/584475, https://go.dev/cl/584476) -->

### Vet {#vet}

<!-- go.dev/issue/46136 -->
The `go vet` subcommand now includes the
[stdversion](https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/stdversion)
analyzer, which flags references to symbols that are too new for the version
of Go in effect in the referring file. (The effective version is determined
by the `go` directive in the file's enclosing `go.mod` file, and
by any [`//go:build` constraints](https://pkg.go.dev/cmd/go#hdr-Build_constraints)
in the file.)

For example, it will report a diagnostic for a reference to the
`reflect.TypeFor` function (introduced in go1.22) from a file in a
module whose go.mod file specifies `go 1.21`.

### Cgo {#cgo}

<!-- go.dev/issue/66456 -->
[cmd/cgo] supports the new `-ldflags` flag for passing flags to the C linker.
The `go` command uses it automatically, avoiding "argument list too long"
errors with a very large `CGO_LDFLAGS`.

### Trace {#trace}

<!-- go.dev/issue/65316 -->
The `trace` tool now better tolerates partially broken traces by attempting to
recover what trace data it can. This functionality is particularly helpful when
viewing a trace that was collected during a program crash, since the trace data
leading up to the crash will now [be recoverable](/issue/65319) under most
circumstances.