It is very simple to build a go environment under Linux: 1. Download go1.2.1.linux-386.tar.gz, there are similar packages everywhere on the Internet, and put it in the linux directory. taogeqq@taogeqq-virtual-machine:~/myspace$ ls a.out go1.2.1.linux-386.tar.gz test.cpp test.go taogeqq@taogeqq-virtual-machine:~/myspace$ 2. Switch to the root user, unzip it under root, and install it after unzipping. What a green software: root@taogeqq-virtual-machine:/home/taogeqq/myspace# tar zxvf go1.2.1.linux-386.tar.gz -C /usr/local/ As you can see, there is an additional go directory under the directory: root@taogeqq-virtual-machine:/home/taogeqq/myspace# ls /usr/local bin etc games go include lib man sbin share src root@taogeqq-virtual-machine:/home/taogeqq/myspace# At this point, the go environment is installed and you can now exit the root user 3. Write a test.go file and test: taogeqq@taogeqq-virtual-machine:~/myspace$ ls a.out go1.2.1.linux-386.tar.gz test.cpp test.go taogeqq@taogeqq-virtual-machine:~/myspace$ taogeqq@taogeqq-virtual-machine:~/myspace$ cat test.go package main import "fmt" func main(){ fmt.Println("hello world") fmt.Println("This is my first Go code") } taogeqq@taogeqq-virtual-machine:~/myspace$ taogeqq@taogeqq-virtual-machine:~/myspace$ /usr/local/go/bin/go run test.go hello world This is my first Go code taogeqq@taogeqq-virtual-machine:~/myspace$ The expected results were obtained. There is a problem. Let's try it by executing go run test.go: taogeqq@taogeqq-virtual-machine:~/myspace$ go run test.go The program 'go' is not installed. You can install it using the following command: sudo apt-get install golang-go taogeqq@taogeqq-virtual-machine:~/myspace$ It can be seen that you can use Now that we have installed it, we can ignore taogeqq@taogeqq-virtual-machine:~/myspace$ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games taogeqq@taogeqq-virtual-machine:~/myspace$ taogeqq@taogeqq-virtual-machine:~/myspace$ vim /home/taogeqq/.bash_profile taogeqq@taogeqq-virtual-machine:~/myspace$ taogeqq@taogeqq-virtual-machine:~/myspace$ cat /home/taogeqq/.bash_profile export PATH=$PATH:/usr/local/go/bin/ taogeqq@taogeqq-virtual-machine:~/myspace$ taogeqq@taogeqq-virtual-machine:~/myspace$ source /home/taogeqq/.bash_profile taogeqq@taogeqq-virtual-machine:~/myspace$ taogeqq@taogeqq-virtual-machine:~/myspace$ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/go/bin/ taogeqq@taogeqq-virtual-machine:~/myspace$ taogeqq@taogeqq-virtual-machine:~/myspace$ go run test.go hello world This is my first Go code taogeqq@taogeqq-virtual-machine:~/myspace$ Among them, /home/taogeqq is the home directory of taogeqq. It's fun to play with things under Linux, but NM's Windows registry really annoys me. Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: Application scenarios and design methods of MySQL table and database sharding
>>: vue2.x configuration from vue.config.js to project optimization
Recent experience in installing mysql5.7.17 free ...
1. Download the mysql repo source $ wget http://r...
Table of contents Isolate Data Columns Prefix Ind...
Table of contents Written in front Environment de...
Table of contents 1. Purpose 2. Grammar 3. Practi...
● I was planning to buy some cloud data to provid...
Three ways to introduce CSS 1. Inline styles Adva...
1. haslayout and bfc are IE-specific and standard ...
First, you need to determine which fields or fiel...
Table of contents Preface: accomplish: Summarize:...
What is a directive? Both Angular and Vue have th...
Table of contents 1. v-for: traverse array conten...
Table of contents 1. One-way value transfer betwe...
Dig Introduction: Dig is a tool that queries DNS ...
Before reading this article, I hope you have a ba...