Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Steps for installation and configuration of Golang

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "the installation and configuration steps of Golang". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the steps of installing and configuring Golang.

Golang installation and configuration

One, Golang installation

(1), download

Golang is supported on both Mac,Windows and Linux, and you can download binaries for the corresponding platform from https://golang.org/dl/. The website is not easy to visit in China, so you can visit https://www.studygolang.com/dl to download the installation software.

Mac OS downloads the osx installer from https://golang.org/dl/. Double-click to start the installation. As prompted, this should press the roll Golang in / usr/local/go and will also be added to your PATH environment variable in the folder / usr/local/go/bin.

Windows downloads the MSI installer from https://golang.org/dl/. Double-click to start the installation and follow the prompts. This will install Golang:\ Go in location C and add the directory c:\ Go\ bin to your path environment variable.

Linux downloads the tar file from https:/golang.org/dl/ and decompresses it to / usr/local. Add / usr/local/go/bin to the PATH environment variable, which should be installed in linux.

Second, install and configure environment variables under windows system

(1) the installation steps are very simple, all the way to the end.

(2) configure environment variables

1. Configure environment variables

Note: if it is a msi installation file, the environment variable of the Go language will be set automatically.

My computer-right-click "Properties"-"Advanced system Settings"-"Environment variables"-"system variables"

Now suppose Go is installed on disk C and in the directory.

New:

GOROOT: Go installation path (for example: C:\ Go)

The path to the GOPATH:Go project (for example: e\ go). If there is more than one, add it separated by a semicolon

Path: add: C:\ Go\ bin;%GOPATH%\ bin to path

You need to configure the executable directory in GOPATH into the environment variable, otherwise the third-party go tools you download will not be available.

The working directory is the place where we store the source code for development, corresponding to the environment variable GoPATH in Go. After this environment variable is specified, the files generated by compiling the source code and so on will be placed in this directory. The configuration of the GOPATH environment variable will be configured in the system variable under Windows by referring to the installation Go above.

There are three main directories under GOPATH: bin, pkg, and src. The bin directory mainly violates the executable files; the pkg directory stores compiled library files, mainly * .a files; and the src directory mainly stores Go source files.

2. Check whether the installation and configuration is successful.

Use the shortcut key win+ R, type cmd, open the command line prompt, and enter

Go env # View the configuration information of go

Go version # check the version number of go

III. Installation and configuration of mac system

(1) installation

Double-click the pkg package and follow the instructions to install it successfully. Enter go version on the command line to get the version number of go, which means the installation is successful.

(2) configure environment variables

Open the terminal to enter and exit cd ~ enter the user home directory

Enter the ls-all command to check the passbook. Bash_profile

Exists to open a file using both vim .bash _ profile

Enter I to enter vim editing mode

Enter the following code, where GOPATH: the root directory of daily development, and GOBIN: is the bin directory under GOPATH.

Export GOPATH = / Users/steven/Documents/gp_project

Export GOROOT=/Usr/local/go

Export GOBIN=$GOROOT/bin

Export PATH=$PATH:$GOBIN

6. Click ESC, and type: wq to save and exit editing, you can enter vim .bash _ profile to see if the save is successful.

7. Enter source ~ / .bash_profile to complete the configuration of golang editing variables, and there is no prompt for successful configuration.

8. Enter go env to view the configuration results

At this point, I believe that everyone on the "Golang installation and configuration steps" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report