头图
Let's explore the charm of GO language

Introduction

Go is an open source programming language that makes it easy to construct simple, reliable and efficient software.
Go was developed by Robert Griesemer, Rob Pike, Ken Thompson at the end of 2007, and later joined Ian Lance Taylor, Russ Cox, etc., and was finally open sourced in November 2009, and Go 1 stable was released earlier in 2012. Version. Now Go development is completely open and has an active community.

feature

  • Simple, fast and safe
  • Parallel, fun, open source
  • Memory management, array security, fast compilation

    Environment setup

    1. Download the installation package

    1.1 You can visit GO language Chinese website download the 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 bit slow):

    go1.17.windows-amd64.msi

    1.3 Use the next installation method to install it. Note here that the address should be in the root directory as much as possible. I installed it in the root directory of Disk D:

    image.png

    2. Configure environment variables

    Here I have configured all environment variables into user variables

    2.1 Configure GOPATH and GOROOT

    image.png

    2.2 Configure Path

    image.png

    3. Verify the installation result

    3.1 View version number
    go version

    image.png

    3.2 View related configuration
    go env

    image.png

    4. Change the domestic mirror

    The initial settings are as follows:
    image.png

    4.1 First open the go module
    go env -w GO111MODULE=on     // Windows
    export GO111MODULE=on        // macOS 或 Linux
    4.2 Configure GOPROXY

    Ali Cloud:

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

    Qiniu Cloud:

    go env -w GOPROXY=https://goproxy.cn      // Windows  
    export GOPROXY=https://goproxy.cn         // macOS 或 Linux
    4.3 Cancel the verification package

    Go 1.13 sets the default GOSUMDB=sum.golang.org, which is used to verify the validity of the package. This URL 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 或 Linux

    image.png

5. Have fun and start programming

5.1 Install VS code

Visit the official website to download the installation package for the corresponding platform:
image.png

5.2 Next installation method

Don't say anything

5.3 Install plugin

Just install two plug-ins here, one for Sinicization, one for GO, and one for running code
image.png

5.4 Get ready

Here you need to create three new folders, namely src, bin and pkg
image.png
Open the src folder with VS code and create a new file, here everyone is free:
image.png

5.5 Let's start writing hello world

Create a new first.go file

package main

import "fmt"

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

Run it directly:
image.png

Personal blog address

http://www.zhouzhaodong.xyz/


周兆东
107 声望21 粉丝

一个java小白的成长之路。。。