Question about Golang runtime enviroment

266 views
Skip to first unread message

louis...@gmail.com

unread,
Nov 10, 2014, 7:09:01 AM11/10/14
to golan...@googlegroups.com
Hi all,

I wrote a program with golang, and go build in one machine.
Then i copy the generated program to another machine which have no golang installed.

But I found the program works well on another machine, So i want to know the golang enviroment
is just needed when build the program, after the program built, it can run any where (even without golang enviroment)?

Am i right?

Any idea will be appreciated!

korn...@gmail.com

unread,
Nov 10, 2014, 7:58:30 AM11/10/14
to golan...@googlegroups.com
Hi,
as long as your programs are pure Go there should be no problems executing binaries on different machines with the same architectures & operating systems (assuming standard compilation). Go programs are statically linked, you don't need to bundle any libraries or "golang environment" with them.

Best,
Kornel

korn...@gmail.com

unread,
Nov 10, 2014, 8:00:34 AM11/10/14
to golan...@googlegroups.com
Also, this kind of questions are better suited for the golang-nuts and not golang-dev.

Kornel

On Monday, November 10, 2014 12:09:01 PM UTC, louis...@gmail.com wrote:

Russ Cox

unread,
Nov 10, 2014, 10:01:52 AM11/10/14
to louis...@gmail.com, golang-dev
On Mon, Nov 10, 2014 at 7:09 AM, <louis...@gmail.com> wrote:
I wrote a program with golang, and go build in one machine.
Then i copy the generated program to another machine which have no golang installed.

But I found the program works well on another machine, So i want to know the golang enviroment
is just needed when build the program, after the program built, it can run any where (even without golang enviroment)?

Yes, that is correct. The running program needs only the final binary.

Russ

louis.hust

unread,
Nov 10, 2014, 11:06:04 AM11/10/14
to Russ Cox, golang-dev
Thank you for your reply,
Golang is amazing!

louis...@gmail.com

unread,
Nov 10, 2014, 8:33:57 PM11/10/14
to golan...@googlegroups.com, korn...@gmail.com
Ok, thanks for your remind

在 2014年11月10日星期一UTC+8下午9时00分34秒,korn...@gmail.com写道:
Reply all
Reply to author
Forward
0 new messages