Introduction to go language - (I) environment construction

Zhou Zhaodong 2021-09-15 08:53:39
Let's explore GO The charm of language

brief introduction

Go Is an open source programming language , It makes construction simple 、 Reliable and efficient software becomes easy .
Go It's from 2007 Year end by Robert Griesemer, Rob Pike, Ken Thompson Host development , Later I joined in Ian Lance Taylor, Russ Cox wait forsomeone , And finally 2009 year 11 In open source , stay 2012 Released earlier this year Go 1 Stable version . Now? Go The development of is completely open , And have an active community .

features

  • concise 、 Fast 、 Security
  • parallel 、 Interesting 、 Open source
  • memory management 、 Array security 、 Compile quickly

    Environment building

    1. Download installation package

    1.1 You can visit GO Chinese language network Download installation package :

    image.png

    1.2 If you can't download it, you can directly use the installation package I have downloaded ( Maybe the download is a little slow ):

    go1.17.windows-amd64.msi

    1.3 Use the next installation method to install , Note here that the address should be in the root directory , I just installed D Packing list :

    image.png

    2. Configure environment variables

    Here I have configured the environment variables into the user variables

    2.1 To configure GOPATH and GOROOT

    image.png

    2.2 To configure Path

    image.png

    3. Verify installation results

    3.1 View version number
    go version

    image.png

    3.2 Check the configuration
    go env

    image.png

    4. Change the domestic image

    The initial settings are as follows :
    image.png

    4.1 First of all, open go module
    go env -w GO111MODULE=on // Windows
    export GO111MODULE=on // macOS or Linux
    4.2 To configure GOPROXY

    Alibaba cloud :

    go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/ // Windows
    export GOPROXY=https://mirrors.aliyun.com/goproxy/ // macOS or Linux

    Qiniuyun :

    go env -w GOPROXY=https://goproxy.cn // Windows
    export GOPROXY=https://goproxy.cn // macOS or Linux
    4.3 Cancel validation package

    Go 1.13 Default is set GOSUMDB=sum.golang.org, Is used to verify the validity of the package . This website may not be accessible due to the wall , So you can use the following command to close :

    go env -w GOSUMDB=off // Windows
    export GOSUMDB=off // macOS or Linux

    image.png

5. Start programming happily

5.1 install VS code

visit Official website , Download the installation package of the corresponding platform :
image.png

5.2 Next installation method

Stop talking, huh

5.3 Installing a plug-in

Just install two plug-ins here , A Chinese , One GO, There is also a to run the code
image.png

5.4 Get ready

Here you need to create three new folders , Namely src,bin and pkg
image.png
use VS code open src This folder and create a new file , Everyone here is free :
image.png

5.5 Start writing hello world Well

Create a new one first.go file

package main
import "fmt"
func main() {
fmt.Printf("hello world !!!")
}

Run directly :
image.png

Please bring the original link to reprint ,thank
Similar articles

2021-09-15

2021-09-15

2021-09-15