Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Go Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-go-knowledge-patch)
---
name: go-knowledge-patch
description: Go
version: "1.27.4"
license: MIT
metadata:
author: Nevaberry
---
# Go compatibility guidance
Load this skill when updating Go code, build scripts, tests, or runtime settings,
or when using the language and standard-library APIs described here.
Use the topic references for complete details and version-specific behavior.
## Topic index
| Reference | Topics |
| --- | --- |
| [Build, linking, and platforms](references/build-linking-and-platforms.md) | Bootstrap requirements, cgo, linkers, executable metadata, operating systems, architectures, WebAssembly |
| [Cryptography, TLS, and X.509](references/crypto-tls-and-x509.md) | Randomness, signatures, key encodings, TLS negotiation, certificates, FIPS, timing, secret cleanup |
| [Filesystems, data, and encoding](references/filesystem-data-and-encoding.md) | Directory roots, symlinks, Windows files and users, process handles, archives, JSON, JPEG, DEFLATE, SQL errors |
| [Language and core library](references/language-and-core.md) | Generic methods, struct literals, inference, ASTs, types, reflection, UUIDs, Unicode, SIMD |
| [Networking and HTTP](references/networking-and-http.md) | DNS, sockets, routing, proxies, cookies, connection reuse, HTTP/2, HTTP tests |
| [Runtime and observability](references/runtime-and-observability.md) | CPU limits, timers, panic behavior, garbage collection, cleanups, traces, profiles |
| [Tooling, modules, and testing](references/tooling-modules-and-testing.md) | Security updates, release support, command migrations, modules, documentation, vet, test output, artifacts, concurrency tests |
## Breaking changes and deprecations
### Security updates
Upgrade Go 1.27 installations to Go 1.27.4 for security fixes in cgo, the `go`
command, the compiler, the linker, and `net/http`. It also includes the earlier
security fixes shipped in Go 1.27.3 and Go 1.27.2; the tooling reference lists
the affected packages.
### Retired commands, settings, and representations
In Go 1.27, a removed setting in a `go.mod` `godebug` entry or a `//go:debug`
directive is accepted only at its final default value. The Go command rejects
a declaration selecting an older behavior.
- `asynctimerchan` was removed; timer channels from package `time` are always synchronous.
- `gotypesalias` was removed; `go/types` always represents aliases with `*types.Alias` nodes.
- The TLS settings `tlsunsafeekm`, `tlsrsakex`, `tls3des`, `tls10server`, and `x509keypairleaf` were removed.
- Remove `GOEXPERIMENT=goroutineleakprofile` from Go 1.27 build scripts: the experiment setting was deleted, and the profile is available without it.
- The Go command dropped `bzr` support; Bazaar-hosted modules need another distribution path, such as a module proxy.
From Go 1.26, replace `go tool doc` in scripts with `go doc`, keeping the same
arguments and flags. In Go 1.27, the `fmtappendf` modernizer was removed and
`waitgroup` was renamed to `waitgroupgo`.
### API migrations
`httputil.ReverseProxy.Director` is deprecated. Use `ReverseProxy.Rewrite` to
inspect the original request and modify the outbound request after hop-by-hop
headers have been removed.
`aes.NewCipher` returns blocks without the old `NewCTR`, `NewGCM`,
`NewCBCEncrypter`, and `NewCBCDecrypter` methods. Pass the block directly to
package functions such as `cipher.NewGCM(block)`.
`parser.ParseDir`, `ast.FilterPackage`, `ast.PackageExports`,
`ast.MergePackageFiles`, and `ast.MergeMode` are deprecated. Use
`ast.PreorderStack` when traversal needs the enclosing-node stack and control
over descent.
### Cryptographic randomness and TLS overrides
In Go 1.26, supplied random readers are ignored by `dsa.GenerateKey`,
`ecdh.Curve.GenerateKey`, `ecdsa.GenerateKey`, randomized ECDSA signing APIs,
`rand.Prime`, and RSA's `GenerateKey`, `GenerateMultiPrimeKey`, and
`EncryptPKCS1v15`. A nil reader in `ed25519.GenerateKey` selects the built-in
secure source even if `crypto/rand.Reader` was overridden.
Use `testing/cryptotest.SetGlobalRandom` to make implicit cryptographic
randomness deterministic for a test, or `GODEBUG=cryptocustomrand=1` for
temporary compatibility.
In Go 1.27, an explicit `tls.Config.CurvePreferences` list can enable hybrid
key exchanges even when `GODEBUG=tlsmlkem=0` or `GODEBUG=tlssecpmlkem=0` is set.
Those switches affect only the default list used when `CurvePreferences` is nil.
The TLS package determines key exchange order.
### Error handling and compatibility-sensitive tests
Check the error from `os.Open` before calling `f.Name()` on the returned file.
Code using a nil result before checking its error can now panic where
Go 1.21 through 1.24 delayed the nil check.
`testing.AllocsPerRun` panics while parallel tests are running. Measure
allocations from a test that runs serially.
The new `image/jpeg` encoder and decoder may produce different encoded bytes
or decoded pixel values. The DEFLATE encoder can produce different bytes for
the same input, including through gzip and ZIP. Exact-output fixtures may need
updates. With `GOAMD64=v3` or higher, fused multiply-add can change exact
floating-point results; `float64(a*b) + c` forces intermediate rounding for
`float64` operands.
`url.Parse` rejects malformed hosts such as `http://::1/` and
`http://localhost:80:80/`. Use brackets for IPv6 literals, as in `http://[::1]/`,
or `GODEBUG=urlstrictcolons=0` for temporary compatibility.
On Windows and macOS, `SSL_CERT_FILE` or `SSL_CERT_DIR` now loads roots from
disk and selects Go's certificate verifier. Set
`GODEBUG=x509sslcertoverrideplatform=0` to retain platform verification.
## Modules, commands, and tests
### Modernization and module configuration
Run `go fix ./...` to apply modernization analyzers. Annotate a forwarding
function with `//go:fix inline` to let the inliner rewrite its call sites as
part of an API migration. Go 1.27 adds `atomictypes`, `embedlit`,
`slicesbackward`, and `unsafefuncs`.
With a stable Go 1.N toolchain, `go mod init` writes `go 1.(N-1).0`;
prerelease toolchains go back two minor versions. To set a different minimum,
run a command such as `go get go@1.26.0` after initialization.
For modules declaring `go 1.27` or later, `go mod tidy` merges scattered
`require` blocks into separate direct and indirect dependency blocks. It
preserves attached comments and moves comments for a block mixing both kinds
of requirements to the direct block.
The `tool` package pattern matches all tools declared in the current module.
Use `go get tool` to upgrade them together or `go install tool` to install
their binaries in `GOBIN`. Use `go list work` to list packages in all workspace
modules; in module mode, `work` matches the single work module's packages.
### Diagnostics, structured output, and artifacts
`go test` runs the `stdversion` vet check by default in Go 1.27. It reports
standard-library symbols newer than the Go version in force for the file,
based on the module's `go` directive and the file's build constraints.
`go build -json` and `go install -json` emit build output and failures as JSON
on stdout. `go test -json` interleaves build and test events; set
`GODEBUG=gotestjsonbuildtext=1` to restore text build output for existing test
consumers. An `"Action":"output"` event can include `OutputType` values such
as `error`, `error-continue`, and `frame`.
`T.Attr`, `B.Attr`, and `F.Attr` attach string metadata emitted as an `attr`
action in `go test -json`. Their `Output()` methods return an `io.Writer`
for indented test log output without source locations.
Write output files under `t.ArtifactDir()`, `b.ArtifactDir()`, or
`f.ArtifactDir()`. Run `go test -artifacts -outputdir="$PWD" ./...` to keep
these directories and log their paths on first use. Without `-artifacts`,
the directories are temporary.
### Deterministic concurrency and HTTP tests
Use `synctest.Test(t, func(t *testing.T) { /* test body */ })` with the
callback's `t`. The old `synctest.Run` API requires `GOEXPERIMENT=synctest`
in Go 1.25 and is scheduled for removal in Go 1.26.
For Go 1.24's `synctest.Run` bubble, once every goroutine is durably blocked,
a pending `synctest.Wait` returns before fake time advances. Call `Wait`
after sleeping to let timer-triggered work settle before asserting on it.
The testing reference includes the example, blocking rules, and shutdown rules.
Use `httptest.NewTestServer` for HTTP tests inside a `testing/synctest`
bubble; it runs on an in-memory fake network. The client from
`httptest.Server.Client()` sends requests for `example.com` and its subdomains
to the test server.
## Language and data APIs
Methods can declare type parameters after the method name. Interface methods
cannot declare type parameters; implement them with non-generic methods of
the required signature. A keyed struct literal accepts any valid field selector
for the struct type, including promoted fields and paths into named nested structs.
A destination function type can infer generic function type arguments in all
assignment contexts, including composite literals, conversions, and channel sends.
The language reference includes examples of these forms.
In Go 1.27, `encoding/json/v2` and `encoding/json/jsontext` are available
without an experiment flag. The former provides configurable marshaling and
unmarshaling with stricter defaults; the latter provides low-level streaming.
`encoding/json` uses the v2 implementation with v1-compatible behavior.
`GOEXPERIMENT=nojsonv2` temporarily restores the original implementation if
the new backend causes compatibility problems.
Use `uuid` to generate and parse UUIDs. `crypto/hpke` implements RFC 9180
and supports post-quantum hybrid KEMs. `crypto/mldsa` implements FIPS 204
ML-DSA signatures, also supported by `crypto/x509` and `crypto/tls`.
Use `GOEXPERIMENT=simd` for experimental portable `simd` and
architecture-specific `simd/archsimd`. The latter revises its amd64 API and
adds 128-bit vectors for ARM64 Neon and WebAssembly; some amd64 processors
also support 256- and 512-bit vectors.
## Runtime and networking
The default `GOMAXPROCS` accounts for Linux cgroup CPU bandwidth limits and
refreshes as available CPUs or limits change. A positive `runtime.GOMAXPROCS`
setting or a `GOMAXPROCS` environment setting overrides these defaults;
`runtime.SetDefaultGOMAXPROCS()` restores them. The respective keys in
`GODEBUG=containermaxprocs=0,updatemaxprocs=0` disable the changes independently.
Use `runtime/trace.FlightRecorder` to keep recent trace data in memory and
`recorder.WriteTo(w)` to save it when an event warrants it. Configure the
capture window and data size with `trace.FlightRecorderConfig`.
`runtime.AddCleanup` callbacks can run concurrently; synchronize shared state
they update. `GODEBUG=checkfinalizers=1` checks finalizers and cleanups during
GC and reports their queue lengths on stderr.
Set `http.Server.Protocols` to allow unencrypted HTTP/2, optionally alongside
HTTP/1 on the same port. On a client, enable only `UnencryptedHTTP2` in
`http.Transport.Protocols` for prior-knowledge HTTP/2 on `http://` URLs.
Set `http.HTTP2Config.StrictMaxConcurrentRequests` to `true` to wait for a
stream slot when an existing HTTP/2 connection reaches its limit.
When `http.Request.Host` is set, `http.Client` uses it for cookie jar lookups
and updates even if the request URL uses a different connection address.
`http.ServeMux` uses 307 Temporary Redirect for trailing-slash redirects,
preserving the method when a client follows the redirect.
Closing an HTTP/1 response body drains a bounded amount of unread content
so the client can reuse the connection. Set `http.Transport.DisableKeepAlives`
to `true` when connection reuse is unwanted.