Installing Go

After the Download is complete, go ahead and launch the installer. The Go installer is shown in Figure 2.4:

Figure 2.4: The Go installer

Follow the onscreen prompts of the installer, and if the installer asks you to make Go available for all users on the system, make sure that you choose to install Go for all users of the system. You may also be prompted for your system credentials (so that you may install Go for all users on the system). Again, go ahead and provide your system credentials.

Once the installer is complete, you should get the following confirmation from the Go installer:

Figure 2.5: The Go installer reports a successful installation

Once the installer is done, let's open up Command Prompt and inspect where the installer installed the files:

$ which go
/usr/local/go/bin/go

On a macOS system, the Go distribution gets installed to the /usr/local/go directory, and the binaries that come with the Go distribution are installed in the /usr/local/go/bin directory.

If you are new to the Go toolchain, you should use the go help command to get yourself acquainted with the various commands that come with Go:

$ go help
Go is a tool for managing Go source code.

Usage:

go command [arguments]

The commands are:

build compile packages and dependencies
clean remove object files
doc show documentation for package or symbol
env print Go environment information
bug start a bug report
fix run go tool fix on packages
fmt run gofmt on package sources
generate generate Go files by processing source
get download and install packages and dependencies
install compile and install packages and dependencies
list list packages
run compile and run Go program
test test packages
tool run specified go tool
version print Go version
vet run go tool vet on packages

Use "go help [command]" for more information about a command.

Additional help topics:
c calling between Go and C
buildmode description of build modes
filetype file types
gopath GOPATH environment variable
environment environment variables
importpath import path syntax
packages description of package lists
testflag description of testing flags
testfunc description of testing functions
Use "go help [topic]" for more information about that topic.

To ascertain the version of Go installed on your system, you can use the go version command:

$ go version
go version go1.9.1 darwin/amd64
You should have the latest version of Go installed on your system, and you need to have a properly configured Go workspace before you can proceed further.
..................Content has been hidden....................

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