3.3 KiB
Tools
Go command
The go build and go install commands now accept a -json flag that reports
build output and failures as structured JSON output on standard output.
For details of the reporting format, see go help buildjson.
Furthermore, go test -json now reports build output and failures in JSON,
interleaved with test result JSON.
These are distinguished by new Action types, but if they cause problems in
a test integration system, you can revert to the text build output by setting
GODEBUG=gotestjsonbuildtext=1.
Cgo
Cgo supports new annotations for C functions to improve run time
performance.
#cgo noescape cFunctionName tells the compiler that memory passed to
the C function cFunctionname does not escape.
#cgo nocallback cFunctionName tells the compiler that the C function
cFunctionName does not call back to any Go functions.
For more information, see the cgo documentation.
Cgo currently refuses to compile calls to a C function which has multiple
incompatible declarations. For instance, if f is declared as both void f(int)
and void f(double), cgo will report an error instead of possibly generating an
incorrect call sequence for f(0). New in this release is a better detector for
this error condition when the incompatible declarations appear in different
files. See #67699.
Vet
The new tests analyzer reports common mistakes in declarations of
tests, fuzzers, benchmarks, and examples in test packages, such as
malformed names, incorrect signatures, or examples that document
non-existent identifiers. Some of these mistakes may cause tests not
to run.
This analyzer is among the subset of analyzers that are run by go test.
The existing printf analyzer now reports a diagnostic for calls of
the form fmt.Printf(s), where s is a non-constant format string,
with no other arguments. Such calls are nearly always a mistake
as the value of s may contain the % symbol; use fmt.Print instead.
See #60529.
The existing buildtag analyzer now reports a diagnostic when
there is an invalid Go major version build constraint
within a //go:build directive. For example, //go:build go1.23.1 refers to
a point release; use //go:build go1.23 instead.
See #64127.
The existing copylock analyzer now reports a diagnostic when a
variable declared in a 3-clause "for" loop such as
for i := iter(); done(i); i = next(i) { ... } contains a sync.Locker,
such as a sync.Mutex. Go 1.22 changed the behavior
of these loops to create a new variable for each iteration, copying the
value from the previous iteration; this copy operation is not safe for locks.
See #66387.
GOCACHEPROG
The cmd/go internal binary and test caching mechanism can now be implemented
by child processes implementing a JSON protocol between the cmd/go tool
and the child process named by the GOCACHEPROG environment variable.
This was previously behind a GOEXPERIMENT.
For protocol details, see #59719.