O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building and running Go programs

Let's create a simple "hello world" program to check our Go setup.

We start out by creating a directory for our new program inside the src directory of our Go workspace, as shown here:

$ cd $GOPATH/src$ mkdir hellogopher

Now, using your favorite text editor, let's create a hellogopher.go source file in the hellogopher directory with the following contents:

package mainimport "fmt"func main() {  fmt.Println("Hello Gopher!")}

To build and run this program in one step, you can issue the go run command:

$ go run hellogopher.goHello Gopher!

To produce a binary executable file that will exist in the current directory, you can issue the go build command:

$ go build

To build a binary executable and automatically move ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required