[Solved] How do I run a GO executable? [closed]


However, running either of them gives an error saying: package hello_world is not in GOROOT (/usr/local/go/src/hello_world)

You haven’t actually said what you’re doing to provoke this error, but it sounds like you’re almost certainly running go run hello_world. Once you’ve build an executable, Go (the language) and go (the command) are no longer involved. Binaries run independently of their compiler, which may be surprising to you if you’re coming from an interpreted language background.

You run any given executable by typing its name (if it’s in your path) or by typing the path to it (ie ./hello_world) and then pressing “return”.

1

solved How do I run a GO executable? [closed]