The function Go runs most inside loops
encoding/json.Unmarshal sits inside a loop at 51% of its 172,393 production calls.
encoding/json.Unmarshal
insights
Every count on this page is derived from the snapshot: 9,201 functions, 29.36M callsites, 47 mapped projects. Here is what stands out: the loops Go runs hottest, the functions everyone reaches for, and the long tail of everything else. 27 facts in all.
deal me a curiosity
The function Go runs most inside loops
encoding/json.Unmarshal sits inside a loop at 51% of its 172,393 production calls.
87,194 in-loop calls. The function Go runs most inside loops.
The function Go runs most inside loops
encoding/json.Unmarshal sits inside a loop at 51% of its 172,393 production calls.
encoding/json.Unmarshal
Half of all in-loop work comes from a handful of functions
Half of every production call that runs inside a loop traces back to just 67 of the 9,201 ranked functions.
The busy function that almost never leaves a loop
Among functions with real volume, time.Sleep runs inside a loop more than any other, 62% of its 7,422 production calls.
time.Sleep
The function with the widest reach across the ecosystem
fmt.Sprintf is called from 1,689 of the 2,029 modules in the corpus, roughly 1 in every 1.2.
fmt.Sprintf
The function one codebase hammers harder than anyone
github.com/Azure/go-autorest/autorest.NewErrorWithError makes 215,125 production calls from just 2 modules, about 107,563 calls per module. High volume, almost no breadth.
github.com/Azure/go-autorest/autorest.NewErrorWithError
True ubiquity is rare
Only 20 functions are called in at least half of the 2,029 modules in the corpus. Almost everything else is niche.
The function nearly every project reaches for first
fmt.Errorf is the single most-called function in 33 of the 47 projects mapped, the common denominator of Go.
fmt.Errorf
The heaviest caller of them all
Kubernetes makes 518,892 production calls across 39 modules, more than any other project we mapped.
Kubernetes
Kubernetes' signature call
Kubernetes leans on k8s.io/kubernetes/test/e2e/framework.ExpectNoError harder than the field does. That is 10,641 production calls from its own modules.
k8s.io/kubernetes/test/e2e/framework.ExpectNoError
Terraform's signature call
Terraform leans on github.com/aws/aws-sdk-go/aws.String harder than the field does. That is 6,492 production calls from its own modules.
github.com/aws/aws-sdk-go/aws.String
Kyverno's signature call
Kyverno leans on go.opentelemetry.io/otel/attribute.Key.String harder than the field does. That is 5,202 production calls from its own modules.
go.opentelemetry.io/otel/attribute.Key.String
KubeVirt's signature call
KubeVirt leans on github.com/onsi/gomega.Expect harder than the field does. That is 4,526 production calls from its own modules.
github.com/onsi/gomega.Expect
Go's busiest interface method
github.com/onsi/gomega/types.Assertion.To is dispatched more than any other interface method, 154,901 calls that could land on any implementation.
github.com/onsi/gomega/types.Assertion.To
Interfaces are everywhere, but they carry little traffic
Just 5% of the 14,855,999 calls in the corpus go through an interface. Most Go is concrete.
Everyone writes through the same shape
984 modules call io.Writer.Write, and 99% of those calls are dispatched. The target is a file, a buffer, or a socket, decided at runtime.
io.Writer.Write
The priciest hot path in the corpus
Weighted by how often it runs, encoding/json.Unmarshal is the corpus's most expensive hot path, about 36x the per-call cost of fmt.Sprintf, and 51% of its calls run inside a loop.
encoding/json.Unmarshal
The cheapest call we benchmarked
Of the hot-path functions we benchmarked on darwin/arm64 (Apple Silicon), strconv.FormatBool is the cheapest, about 1.9 nanoseconds per call.
strconv.FormatBool
Go programs compile their patterns once, not in the loop
regexp.MustCompile costs about 31x a fmt.Sprintf per call, but only 2% of its calls sit inside a loop. The expensive part stays out of the hot path.
regexp.MustCompile
The most test-bound function in the corpus
testing.common.Fatalf is called 448,315 times from tests, 98% of all its calls.
testing.common.Fatalf
The third-party helper the test suite can't live without
github.com/stretchr/testify/require.NoError is the most-called third-party function in tests, 298,363 calls, 96% of them in test files.
github.com/stretchr/testify/require.NoError
Even a workhorse leans on code generators
25% of fmt.Errorf's 555,654 calls are emitted by code generators. The rest are hand-written.
fmt.Errorf
How much of Go is written by code generators
9% of every call in the corpus lives in generated code, such as protobuf and cloud SDKs.
The median Go function is barely called at all
Half of the 9,201 ranked functions are called 133 times or fewer in production. The famous ones are the exception.
A tiny fraction of functions does most of the work
The busiest 1% of functions, 92 of them, account for 53% of every production call. A textbook power law.
Ten functions carry a fifth of everything
Just ten functions account for 21% of all 7,550,935 production calls in the corpus.
The standard library punches far above its weight
The 1,526 standard-library functions are 17% of the catalog but do 44% of all production work.
Most catalogued functions are barely used
0% of the 9,201 ranked functions are called at most once in production code, catalogued, but rarely reached for.
Showing 27 of 27 facts.
Facts are superlatives over production calls (test and generated code excluded, except where a fact is explicitly about them). Cost figures are a coarse, input-independent benchmark seed, expressed relative to a fmt.Sprintf call. See the methodology.