How to install golang language programming environment in ubuntun
It is believed that many inexperienced people have no idea about how to install golang language programming environment in ubuntun. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
First download the installation package for goLang using the tool curl:
Sudo curl-O https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz
Then the downloaded installation package is unzipped and a compressed file is extracted via tar.
Sudo tar-xvf go1.9.2.linux-amd64.tar.gz
After unzipping, a go directory is generated.
Use the command line mv to move the directory to the directory / usr/local:
Add the bin folder in the go directory to the environment variable of ubuntu:
Echo 'export PATH=$PATH:/usr/local/go/bin' > > ~ / .profile
Source / .profile
The command line go version displays the version, indicating that the environment variable is in effect.
Use go language to implement a simple program for calculating factorial:
Package mainimport "fmt" func Factorial (n uint64) (result uint64) {if (n > 0) {result = n * Factorial (nmur1) return result} return 1} func main () {var i int = 15 fmt.Printf ("func (% d):% d", I, Factorial (uint64 (I)}
Use go build hello.go to compile to an executable file, and then execute. / hello.
After reading the above, have you mastered how to install the golang programming environment in ubuntun? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!