enitihas
enitihas

Reputation: 915

In what cases are go binaries dynamically linked?

One important feature of the Go programming language is that it produces statically linked binaries. However, when I ran ldd * in my $GOPATH/bin, I found several dynamic executables. Is there a clear set of rules to understand under what circumstances does the go compiler produce dynamically linked binaries?

Upvotes: 5

Views: 4922

Answers (2)

Pharaoh
Pharaoh

Reputation: 752

Go 1.8 has introduced something called Go Plugin which seems to be using dynamic linking.

https://golang.org/pkg/plugin/

Upvotes: 1

Jonathan Hall
Jonathan Hall

Reputation: 79774

When using cgo, which is how Go links to C programs, which can of course use dynamically-linked libraries.

Upvotes: 4

Related Questions