Advanced Language Features Best Practices
Reach for power features only with clear operational need.
Search across all documentation pages
Reach for power features only with clear operational need.
These rules distill the advanced-language-features section: default to portable Go, document release commands, and treat plugins, assembly, and linkname as exceptional.
go:embed, build tags, or -buildmodepprof or benchmarks, not intuition.runtime.GOOS checks with foreign imports. One file per platform scales cleaner in review.embed.FS with fs.Sub for HTTP static routes. Strip prefixes so URL paths stay intuitive.//go:build on new files; migrate legacy // +build on touch. Keep constraints readable with parentheses.GOOS when you ship cross-platform. Windows or darwin catches missing fallbacks early.-ldflags, -tags, and -buildmode in Makefile or CI logs. Reproducible artifacts require copy-paste exact commands.-X main.version=... using the correct import path. Verify with go list -f '{{.ImportPath}}' ./cmd/....-s -w) and debug build targets separate. Operators need symbols during incidents.go.mod/go.sum versions between host and plugin modules. Dependency skew causes subtle crashes at Lookup.plugin for controlled on-prem catalogs..s implementation. //go:build !amd64 (or relevant arch) files are mandatory.//go:linkname in application packages. Restrict to forks of runtime/stdlib patterns with upgrade owners.//go:noinline to tests and benchmarks unless a runtime contract requires it. Do not pessimimize hot production paths..s files exist. amd64-only tests miss broken arm64 syntax.go fix after toolchain upgrades and review diffs. Modernizers catch inline and API migrations early.Demonstrate that runtime file paths or external volumes are unacceptable for deployment or compliance, and that binary size impact is acceptable.
When the code must not compile on other platforms at all (different syscalls, cgo availability), not when users simply toggle features.
Rarely.
Prefer static binaries and service boundaries until a paying customer mandates in-process extension with shared ops control.
Require proof of benchmark improvement, arch fallbacks, and a named owner who will fix breakages on Go upgrades.
No for published docs pages.
Readers need to know which Go release assumptions apply.
Use Advanced Features for embed, tags, buildmode, plugins, assembly, and directives.
Use CGO when the primary problem is C header interop and C memory rules.
Stack versions: This page was written for Go 1.26.x (Green Tea GC default, go fix modernizers - verify patch at build), chi (latest - verify at build), gin (latest - verify at build), echo (latest - verify at build), google.golang.org/grpc (latest - verify at build), sigs.k8s.io/controller-runtime (latest - verify at build), kubebuilder (latest - verify at build), tinygo (latest - verify board targets at build), wazero (latest - verify at build), and golangci-lint (latest - verify linter set at build).
Reviewed by Chris St. John·Last updated Jul 18, 2026