🌝

Go Install

Posted at — Dec 01, 2020
#go

Configuration of golang.

Golang Installation And configuration

Windows

1.Download and Installation

2.Set GOPATH in user environment variable settings and global environment variable settings

For me:

1
C:\work\Go

3.Verify the installation

Command Line:

1
go version

4.Open the GOMOD

Command Line:

1
go env -w GO111MODULE=on

5.Create a golang project by vscode and config the setting json

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
{
    "version": "0.2.0",
    "configurations": [{
            "name": "{yourprojectname}",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${fileDirname}",
            "env": {
                "GOPATH": "{your GOPATH}",
                "GOROOT": "{your GOROOT}"
            },
            "args": [],
            //"showLog": true
        }
    ]
}

Linux

1.Download and Installation

Download the tar.gz file and unzip it to “/usr/local/”

1
tar -C /usr/local -zxvf  gox.xx.x.linux-amd64.tar.gz

2.Config GOROOT

1
vim /etc/profile

Add the following words in the last line

1
2
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin

Save the file and source it

1
source /etc/profile

2.Verify the installation

Terminal:

1
go version

3.Config GOPATH

1
vim ~/.bash_profile

Or

1
vim ~/.bashrc

Add the following words in the last line

1
export GOPATH=$HOME/go

Save the file and source it