Your first Go program

After installing the Go tools successfully on your local machine, you are now ready to write and execute your first Go program. For that, simply open your favorite text editor and type in the simple Hello World program shown in the following code:

package main
import "fmt"
func main() { 
  fmt.Println("Hello, World!")
} 

golang.fyi/ch01/helloworld.go

Save the source code in a file called helloworld.go anywhere inside your GOPATH. Then use the following Go command to compile and run the program:

$> go run helloworld.go 
Hello, World!

If all goes well, you should see the message Hello, World! output on your screen. Congratulations, you have just written and executed your first Go program. Now, let us explore the attributes and characteristics of the Go language at a high level.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.60.249