Go SDK Command

Introduction

To confirm everything is working, open a terminal and type the following:

go version 

The Go tool set has several different commands. You can pull up a list of those commands by typing:

go help 

Open your text editor, create a new file, and enter the following:

package main /*from  www.  ja  v  a 2 s . c o m*/

import "fmt" 

// this is a comment 

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

Save it as main.go.

Open up a new terminal and type in the following:

go run main.go 

You should see Hello, World displayed in your terminal.

The go run command will do the following:

  • takes the files separated by spaces,
  • compiles them into an executable saved in a temporary directory, and then
  • runs the program.



PreviousNext

Related