Link-Time Optimization (LTO) in Go is not a standard feature; the compiler optimizes packages individually before linking them together. To achieve cross-package optimizations, you must use the -ldflags=-s -w flags to strip debug info and reduce binary size, or rely on the compiler's automatic inlining which works across package boundaries if functions are small enough.
go build -ldflags="-s -w" -o myapp main.go
For advanced control over inlining, use //go:noinline or //go:inline directives in your source code to force or prevent specific function optimizations.