Home > Backend Development > Golang > golang installation steps

golang installation steps

angryTom
Release: 2020-02-15 16:21:43
Original
3263 people have browsed it

golang installation steps

golang installation steps

The installation package download address is: https://golang.org/dl/.

If you cannot open it, you can use this address: https://golang.google.cn/dl/.

golang installation steps

UNIX/Linux/Mac OS X, and FreeBSD installation

#1. Download the binary package: go1.4.linux- amd64.tar.gz.

2. Unzip the downloaded binary package to the /usr/local directory.

tar -C /usr/local -xzf go1.4.linux-amd64.tar.gz
Copy after login

3. Add the /usr/local/go/bin directory to the PATH environment variable:

export PATH=$PATH:/usr/local/go/bin
Copy after login

Note: Under the MAC system, you can use the installation package ending with .pkg to double-click it directly. Installation, the installation directory is under /usr/local/go/.

Installation under Windows system

You can use the .msi suffix under Windows (the file can be found in the download list, such as go1.4.2.windows-amd64.msi) installation package to install.

By default, the .msi file will be installed in the c:\Go directory. You can add the c:\Go\bin directory to the Path environment variable. After adding it, you need to restart the command window for it to take effect.

Installation Test

Create the working directory C:\>Go_WorkSpace.

test.go file code:

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

Use the go command to execute the above code and the output result is as follows:

C:\Go_WorkSpace>go run test.goHello, World!
Copy after login

Related recommendations: golang tutorial

The above is the detailed content of golang installation steps. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template