Why is Golang popular in China

Configure the Golang development environment on Linux

A few days ago I accidentally saw the news of the Golang development being pushed by WeChat. When I saw that Golang was so great, I suddenly wanted to learn to walk on a whim. If you want good results, the first thing you need to do is sharpen your tools. If you want to do Go development, you must first configure the Go development environment (just like installing and configuring the JDK when developing Java). After searching online for a long time, I haven't found a satisfactory tutorial (it seems Golang is still not popular in China) so I explored it myself and stepped on many pits. I take it up here in the hope of helping others and avoiding detours. Since I moved all development except C / C ++ to Linux, I installed and configured golang on Ubuntu. In fact, the installation on Windows is similar.

1 First, go to the Golang official website to download the Golang installation package

Golang's official website is relatively slow to visit in China. It is recommended to download it from a domestic website https://studygolang.com/dl and select the appropriate installation package for different platforms

Download .png

2 installation

Double-click Windows and select the directory where you want it to be installed. Linux usage Extract the command/ urs / local / Table of Contents. The decompression is complete, the next step

3 Configure environment variables

I want to say something about mmp here after configuring it using the online tutorial or command promptProgram go was not installed, Or justThe go install command cannot be usedSo I crossed the river by feeling the stones and finally passed by. Not much to say, start configuring.
in or in the user directory Configure environment variables in the file.
The difference between the two is inThe following configuration works for all users: The media configuration only affects the current user. I'm configured to run in command, add on the last line of the file

Don't worry, explain line by line

Set the installation location of golang, we will extract it to the directory, the folder must be the root directory of the go environment. Just open it, don't have another one after the catalog's table of contents.

Directory is running after the executable file has been generated

It is our working directory. Generally we set it to the user directory. This should be configured according to the actual situation of your computer. Introduction to the working directory structure of go. There are 3 subdirectories under the working directory that we have specified

  • bin Storage folder For the executable file generated by the command, you can add the path ** $ GOBIN ** to the PATH environment variable so that you can use the program generated by our go development directly in the terminal.
  • The pkg folder contains files generated by go compilation.
  • Src stores our Go source code and the codes of different projects are differentiated by package names.

After adding, save and exit and then run, or log out and log back in. Then run, when you view the version information, it says the environment has been set up.

Next, write a demo to have a try. In the working directory we configured (with It can be used in this directory The command must be in the working directory.) My working directory is newtest.goWrite a few lines of code

Then execute, use A, execute command, output, display success
Try nextAnd then in the working directoryThe directory will be generatedFile the whole Golang development environment is configured.

Finally, I recommend a couple of IDEs, how can most development without an IDE be the first recommendationJetbrainsHome products, Jetbrains IDE is very good regardless of language, especially Jetbrains IDE interface and keyboard shortcuts are identical, familiar with one, can all use and cross-platform. Golang evolution can be usedJetbrains golandThis is an IDE specially designed for the Golang by Jetbrains. It can also be used in the form of IDEA + Go plug-ins. I only use IDEA + plug-ins and I feel pretty good. and alsoVisual Studio Code + Go pluginIt's also very good, the advantage of vscode is its ease.

### goHow how to use proxy:

Obtain it from https://github.com/goproxy/goproxy.cn

// The cmd command line for win10 to change go env is:

Get going is too slow

Step 1: Use an IP search tool to find the appropriate IP address.
IP lookup toolhttp: //ipaddress.com/ip-lookup/

Obtain the corresponding IP from github.com

Request the corresponding IP from github.global.ssl.fastly.net

Step 2: Write the appropriate IP to the host
192.30.253.112 github.com
151.101.44.249 github.global.ssl.fastly.net
Step 3: Have fun with Github and go :)
Host write
192.30.253.112 github.com
151.101.44.249 github.global.ssl.fastly.net
Step 3: Have fun with Github and go :)
Original link: https://blog.csdn.net/github_34889651/article/details/53471108