Eyal
Eyal

Reputation: 1110

Go run takes multiple seconds to compile hello world binary

When executing go run on a hello world program it takes several seconds, which seems slow.

~/code/hello-word$ time go run .
Hello world

real    0m2.119s
user    0m0.113s
sys 0m0.291s

Output of go env is

AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN='/Users/edechter/go/bin'
GOCACHE='/Users/edechter/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/edechter/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/w0/bs3zf22158j_c2kgk55d0t6c0000gp/T/go-build678553452=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/edechter/code/hello-word/go.mod'
GOMODCACHE='/Users/edechter/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/edechter/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.24.0/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/edechter/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.24.0/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.0'
GOWORK=''
PKG_CONFIG='pkg-config'

The package itself contains a single file:

package main

import "fmt"

func main() {
    fmt.Println("Hello world")

and a go.mod file

module examples.com/edechter/hello-world

go 1.24.0

What can I try to debug this?

Upvotes: 0

Views: 78

Answers (0)

Related Questions