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-nevaberry-plugins)
---
name: go-knowledge-patch
description: Go
version: "1.27.4"
license: MIT
metadata:
author: Nevaberry
---
# Go compatibility guidance
Load this skill when migrating Go code, updating build scripts, diagnosing
runtime or test behavior, or using the APIs described below. Consult the topic
references for detailed conditions, platform differences, and version attribution.
## Reference index
| Reference | Topics |
| --- | --- |
| [Build, Linking, and Platforms](references/build-linking-and-platforms.md) | Toolchain bootstrap, cgo, linker flags, debug information, operating systems, WebAssembly |
| [Cryptography, TLS, and X.509](references/crypto-tls-and-x509.md) | Signing, randomness, FIPS, key exchanges, certificates, timing, secret cleanup |
| [Filesystems, Data, and Encoding](references/filesystem-data-and-encoding.md) | Directory roots, symlinks, Windows handles, JSON, compression, images, SQL errors |
| [Language and Core Library](references/language-and-core.md) | Generics, literals, reflection, ASTs, types, Unicode, SIMD |
| [Networking and HTTP](references/networking-and-http.md) | DNS, sockets, routing, redirects, cookies, HTTP protocols, test servers |
| [Runtime and Observability](references/runtime-and-observability.md) | Scheduling, traces, leak profiles, GC, panic diagnostics, cleanup |
| [Tooling, Modules, and Testing](references/tooling-modules-and-testing.md) | Security updates, module management, documentation, modernizers, vet, fake time, artifacts |
## 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`. This also includes the earlier
Go 1.27.3 fixes for `crypto/x509` and Go 1.27.2 fixes for the `go` command,
`crypto/tls`, `html/template`, `net/http`, `net/textproto`, and `os`.
### Scripts and retired settings
Replace `go tool doc` with `go doc`, passing the same arguments and flags.
The Go distribution ships core tool binaries such as the compiler and linker;
invoke other tools through `go tool`, which can build and run them on demand.
In Go 1.27, remove `GOEXPERIMENT=goroutineleakprofile` from build scripts:
the setting was deleted, and the `goroutineleak` profile is available without it.
The runtime removed `asynctimerchan`; timer channels from package `time` are
always synchronous. The `gotypesalias` setting was removed, and `go/types`
always represents aliases with `*types.Alias` nodes.
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 declarations
that select an older behavior.
The `fmtappendf` analyzer was removed, and `waitgroup` was renamed to
`waitgroupgo`. Bazaar module fetching no longer supports `bzr`; modules hosted
there need another distribution path, such as a module proxy.
### HTTP migration
`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.
`url.Parse` rejects malformed hosts such as `http://::1/` and
`http://localhost:80:80/`. Write IPv6 literals with brackets, as in
`http://[::1]/`, or use `GODEBUG=urlstrictcolons=0` for temporary compatibility.
`http.ServeMux` uses 307 Temporary Redirect for trailing-slash redirects,
preserving the request method when a client follows the redirect.
When `http.Request.Host` is set, `http.Client` uses that host for cookie jar
lookups and updates, even if the request URL points to a different address.
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.
### Cryptography and trust configuration
`aes.NewCipher` returns blocks without the previously available `NewCTR`,
`NewGCM`, `NewCBCEncrypter`, and `NewCBCDecrypter` methods. Pass the block to
package functions such as `cipher.NewGCM(block)`.
The `tlsunsafeekm`, `tlsrsakex`, `tls3des`, `tls10server`, and `x509keypairleaf`
GODEBUG settings were removed. An explicit `tls.Config.CurvePreferences` list
can enable hybrid exchanges even with `GODEBUG=tlsmlkem=0` or
`GODEBUG=tlssecpmlkem=0`; those switches affect only the default list used when
`CurvePreferences` is nil. The TLS package determines key exchange order.
Setting `SSL_CERT_FILE` or `SSL_CERT_DIR` on Windows or macOS loads roots from
disk and selects Go's certificate verifier. Use
`GODEBUG=x509sslcertoverrideplatform=0` to retain platform verification.
Supplied readers are ignored by `dsa.GenerateKey`, `ecdh.Curve.GenerateKey`,
`ecdsa.GenerateKey` and the 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`
for deterministic implicit cryptographic randomness in a test, or
`GODEBUG=cryptocustomrand=1` for temporary compatibility.
### JSON and exact-output fixtures
`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 supports low-level streaming.
`encoding/json` uses the v2 implementation with v1-compatible behavior.
If the backend causes compatibility problems, build with
`GOEXPERIMENT=nojsonv2` to restore the original implementation temporarily.
The `image/jpeg` encoder and decoder may produce different encoded bytes or
decoded pixels, so byte-for-byte fixtures can need updates. DEFLATE can produce
different bytes for the same input, including through gzip and ZIP; tests
comparing exact compressed bytes may need updated fixtures.
### Platform and runtime compatibility
Go 1.27 requires macOS 13 Ventura or later. Big-endian `linux/ppc64` uses ELFv2,
requiring Linux 3.13 or a kernel with the support backported, such as RHEL 7's
3.10 kernel. Cgo, PIE, and external linking are supported with an
ELFv2-compatible libc and libraries.
WebAssembly sign-extension and non-trapping float-to-integer conversions are
emitted unconditionally. `GOWASM` options `signext` and `satconv` are ignored;
the target runtime must support those instructions.
Check the error from `os.Open` before calling `f.Name()` on the returned file:
using a nil result before checking the error can now panic where Go 1.21
through 1.24 delayed the nil check. `runtime.AddCleanup` callbacks can run
concurrently, so synchronize any shared state they update.
## Common development tasks
### Modernize code and inspect documentation
Run `go fix ./...` to apply modernization analyzers. Annotate a forwarding
function with `//go:fix inline` to let the inliner rewrite call sites for an API
migration. Additional analyzers include `atomictypes`, `embedlit`,
`slicesbackward`, and `unsafefuncs`.
Run `go doc example.com/pkg@v1.2.3` for version-specific documentation,
`go doc -ex bytes` to list executable examples, or
`go doc bytes.ExampleBuffer` to print a named example's source and comments.
`go test` runs the `stdversion` vet check by default. 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.
### Manage modules and tool dependencies
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.
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 packages in the single work module.
For modules declaring `go 1.27` or later, `go mod tidy` merges scattered
`require` blocks into separate direct and indirect dependency blocks,
preserving attached comments. Comments for a block mixing both kinds move
to the direct block.
### Use generic methods and struct literal selectors
Methods can declare type parameters after the method name; interface methods
cannot. To implement an interface method, declare a non-generic method with
the required signature. `(*rand.Rand).N` in `math/rand/v2` accepts any integer
type and returns that same type, so `r.N(int32(10))` returns an `int32`.
A keyed struct literal accepts any valid field selector for its struct type,
including promoted field names and selector 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.
### Test concurrency and retain artifacts
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. The testing reference preserves
the Go 1.24 fake-time, durable-blocking, and bubble-shutdown guidance.
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.
Write output files under `t.ArtifactDir()`, `b.ArtifactDir()`, or
`f.ArtifactDir()`. Run `go test -artifacts -outputdir="$PWD" ./...` to retain
those directories and log their paths on first use; without `-artifacts`,
the directories are temporary. `testing.AllocsPerRun` panics while parallel
tests are running; measure allocations from a test that runs serially.
### Inspect runtime behavior
Use `runtime/trace.FlightRecorder` to keep recent trace data in memory and
`recorder.WriteTo(w)` to save it when an event warrants it. Tune the capture
window and size with `trace.FlightRecorderConfig`.
The default `GOMAXPROCS` accounts for Linux cgroup CPU bandwidth limits and is
periodically refreshed as available CPUs or limits change. A positive
`runtime.GOMAXPROCS` setting or a `GOMAXPROCS` environment setting overrides
these defaults; `runtime.SetDefaultGOMAXPROCS()` restores them.
`go tool trace -http=:6060 trace.out` binds to localhost. To bind to all IPv4
interfaces, pass `-http=0.0.0.0:6060`.
### Work with directory roots
`os.Root` allows `..` and symbolic links when resolution stays within the
opened directory. On Unix it follows its directory across renames and allows
traversal across mount points, including bind mounts. On Windows the open root
prevents renaming or deleting its directory and rejects reserved device names
such as `NUL` and `COM1`. Consult the filesystem reference for WASI, `GOOS=js`,
and Plan 9 guarantees and the platform difference in `root.Open("a/../b")`.