Go Installation and configuration run

Novice must see Go environment variables configuration and run the full walkthrough

Go download link: studygolang.com/dl

We can directly Go to Go Language Chinese website to find a current stable running of the latest version (currently 2020-11–08 is 1.15.4), and then find a Windows system to download it (as shown in the picture) :

You can download the ZIP package or mSI installation package. To save time, we chose to download a zip package, the first one in the red box, go.15.4.Windows-386.zip

After downloading the package, unzip it to a directory on your computer. This is the directory I unzipped locally, and then go to the bin directory following the unzipped package:

Then right click on this computer (Win7 and other operating system corresponding to open my computer), enter the properties page:

Open advanced System Settings, environment variables, and edit the value of Path in system variables:

Then add the address of the bin directory:

Finally, to check whether the configuration is successful, first, call the command line (shortcut key Win + R), enter CMD:

Enter go version in any directory:

The Go version 1.15.4 we just downloaded appears, la la la ~~ congratulations, the configuration is successful!

Run the Go program

Now we can run our Go program directly from the command line, using the HelloWorld example: Code Portal

First, Go to the Go file directory on the command line, such as my current helloworld. Go in C:\Users\37595\Desktop\ knowledge list \code\ 1_helloWorld:

Two operating modes:
  1. Go build helloWorld ();

Execute the compiled file:

  1. Run the go run command directly:

conclusion

  • Saw the friend may find here, when we configure the language environment did not use the traditional way of installing packages, but directly download the zip file into good the configuration environment variables, it has to do with the difference between msi installation is not our computer registry with writing some configuration information, cannot generate a shortcut.

    So, already familiar with the installation process, or in order to save time, you can directly choose the.zip installation mode, you can also run the Go program!

  • Go program will be executable.exe file after compilation, at this time the file into the computer without installation and configuration Go compilation package can still run, and Java and other programming languages, can also achieve a compilation, run everywhere.

    The difference is that the.class bytecode file generated after Java compilation needs to be run on the JVM (Java Virtual machine), while the.exe file compiled after Go can be opened and run directly on the Windows machine.

    PS: Some operating systems directly open the.exe file will flash back, in this case, you can add a line of input parameters from the keyboard code at the end of the code can be:

     fmt.Scanf("a")
    Copy the code