It's said that Golang is the compiled language, but what does it mean by compiled? If golang application is compiled to machine code, why can't I just distribute the binary (of course on corresponding arch and platform) instead of go install
stuff?
Why Go Programs need runtime support
Once you compile a binary you can distribute it onto machines with the same architecture. go install,
go run,
etc. is just necessary for compilation.
Not just the same, but the target. I build on whatever machine I'm on and deploy on four or five different systems. –
Samora
go install/run
is not related to compiling. –
Hah @Erikw.
go install
compiles and installs, and is how you build a non-main package. go run
compiles in a temp location, then executes the resulting binary. –
Vermifuge @Vermifuge Oh that's true. What I was thinking about is that
install
is not necessary for compilation; go build
would suffice. Useless however since the compiled package would not be installed and thus deleted when $WORK is deleted after the completion of the command. –
Hah One of Go's unique features is that APIs are distributed as source code, not as
.jar
, .dll
, .so
or other binary packages. This is practicable because Go compiles so fast. At a stroke, it solves portability issues very simply, without resorting to needing a virtual machine (JVM etc). The (minor) downside is that producing closed-source APIs is tricky, to say the least. –
Calves @Rick-777, "distributing APIs" (for what it stands) without the source code might be implemented some time later. –
Denton
© 2022 - 2024 — McMap. All rights reserved.
go install
and stuff to run a compiled go binary. – Cosimo