The difference between GO environment variable configuration and system configuration file

Source: Internet
Author: User

Take advantage of the weekend to summarize your understanding of the environment variables for learning and using go. first, GO environment variables

The first step in learning and using Go is to download the installation and configure the environment, download the installation process directly to see the instructions, this is mainly about the environment variables to be configured to understand.

(1) Goroot: The go on the computer installation location, such as I am the installation location in/usr/local/go, I in the configuration file corresponding configuration Goroot=/usr/local/go.

(2) Gobin: Indicates where the compiler and linker are installed, the Go 1.0.3 and later versions are nullable, and the default value $goroot/bin is used.

(3) Gopath: An environment variable that saves the working directory. You can set up multiple working directories, and the remote package will be installed in the first directory when you use go to (Remote Package installation command) later. As my working directory is/home/xiaozhu/go, I correspond to the configuration gopath=/home/xiaozhu/go in the configuration file.

(4) Path: These are just a few parameters configured for go, and to ensure that the configuration can be invoked anywhere, you also need to add the go path to the PATH environment variable. As I add here is the path= $GOROOT/bin: $PATH. At the same time, you can put your own go working directory location, path= $GOPATH/bin: $PATH.

This to, GO environment variable configuration is basically complete, after these settings, you need to enter the terminal Input command source. BASHRC to make these environment variables take effect. Then restart the terminal and enter go env and env to check that the environment variable is set correctly. second, the system configuration file Difference

The above mentioned "configuration file", we know the common configuration files under Linux have/ect/profile,/ETC/BASHRC, ~/.bash_profile and ~/.BASHRC, what is the difference between these four.

(1)/ect/profile: When you log on to the operating system, set the environment information for each user, and the file is executed the first time the user logs on. This means that the file is valid for each shell and is used to obtain the environment information of the system.

(2)/ETC/BASHRC: Every user running the Bash shell executes this file, which is read when the bash shell is opened. In other words, when the user shell executes bash, run the file.

(3) ~/.bash_profile: Each user can use this file to enter the shell information dedicated to their own use, when the user logs on, the file is only executed once. By default, he sets some environment variables to execute the user's. bashrc file.

(4) ~/.BASHRC: Each user's bash shell information, execute this file when the user logs in and each time a new shell is opened. In this file, you can customize personal information that is user-specific.

When the user log on to the system, first read the/etc/profile inside the configuration, and then log in if the ordinary user to read the user's personal ~/.BASHRC configuration.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.