importing Go is static linking or dynamic linking?

149 views
Skip to first unread message

Jessica Park

unread,
Sep 26, 2022, 10:22:43 AM9/26/22
to golang-nuts
When java...
can import .jar ... in this case, we call dynamic link..

How about golang?

Is it dynamic linking or static linking?

I need clear information.
Thank you.

Ian Lance Taylor

unread,
Sep 26, 2022, 10:37:00 AM9/26/22
to Jessica Park, golang-nuts
On Mon, Sep 26, 2022 at 7:22 AM Jessica Park
<outsider...@gmail.com> wrote:
>
> When java...
> can import .jar ... in this case, we call dynamic link..
>
> How about golang?
>
> Is it dynamic linking or static linking?

A pure Go program that does not use cgo will use static linking on
most operating systems.

A mixed Go/C program that does use cgo will use dynamic linking on
most operating systems.

> I need clear information.

A more precise answer will require more details as to exactly what you
are doing and what operating system you are using.

Ian

TheDiveO

unread,
Sep 26, 2022, 10:43:26 AM9/26/22
to golang-nuts
Actually, it depends on which std libs are used. https://www.arp242.net/static-go.html is a concise introduction. net and os/user normally prevent a static binary, unless build tags netgo and osusergo are used.
Reply all
Reply to author
Forward
0 new messages