-trimpath
remove all file system paths from the resulting executable. Instead of absolute file system paths, the recorded file names will begin either a module path@version (when using modules), or a plain import path (when using the standard library, or GOPATH).
— https://pkg.go.dev/cmd/go#hdr-Compile_packages_and_dependencies
Without -trimpath, e.g., go run .
{
"timestamp": "2025-08-15T15:50:30.180273+09:00",
"severity": "INFO",
"source": {
"function": "github.com/cowork-ai/fred.NewHTTPServer.func1.1",
"file": "/Users/wjkoh/fred/http.go",
"line": 34
},
"message": "Starting an HTTP server..."
}With -trimpath, e.g., go run -trimpath .
{
"timestamp": "2025-08-15T15:50:56.45097+09:00",
"severity": "INFO",
"source": {
"function": "github.com/cowork-ai/fred.NewHTTPServer.func1.1",
"file": "github.com/cowork-ai/fred/http.go",
"line": 34
},
"message": "Starting an HTTP server..."
}Check out Go docker images: small and simple for more information. By the way, -ldflags=-s implies -ldflags=-w, so you need -s only according to https://pkg.go.dev/cmd/link#hdr-Command_Line.