1. The first step of GO language

Introduction to Go

Go (also known as Golang ) is a statically strongly typed, compiled language developed by Google's Robert Griesemer, Rob Pike and Ken Thompson. The Go language syntax is similar to C, but its functions include: memory safety, GC (garbage collection), structural form and CSP-style concurrent computing.

Features:
  1. Backed by major manufacturers, Google
  2. Support concurrency (the most significant feature)
  3. Simple syntax and easy to use
  4. Built-in runtime, supports garbage collection
  5. Can be compiled directly into machine code without relying on other libraries
  6. Rich standard library
  7. Cross-platform compilation
Application areas
  1. Server programming
  2. Development cloud platform
  3. Blockchain: Unique advantages, especially encryption algorithms
  4. Distributed Systems
  5. network programming

Install Go

Download address: https://golang.google.cn/dl/,

Installation package
Download the installation package and install it directly.

Please add image description

Set environment variables

Please add image description
Test environment variables successfully

Configure the Go environment
go env

Please add image description

go env -w GO111MODULE="on" 
go env -w  GOPROXY="http://goproxy.cn" 
 
//从powershell 用
$env:GO111MODULE = "on"
$env:GOPROXY = "http://goproxy.cn"
//使用 gomod 管理库,需要vpn上网,所有模组都再github上,需要有git

Please add image description

Please add image description

go get  //类似 go clone

Go development tools

  1. sublime
  2. vim
  3. atom
  4. LiteIDE
  5. eclipse
  6. goland
  7. Use this for vscode , yyds!
VSCODE
  1. Direct installation
  2. Install plugin
1.GO

Please add image description

Please add image description

go run main.go encountered error go.mod file not found in the current directory or any parent directory;

Please add image description

Solution 1:

"The go command now builds packages in module-aware mode by default, even if no go.mod exists.

"You can set GO111MODULE to auto to enable module-aware mode only if a go.mod file exists in the current directory or any parent directory.

go env -w GO111MODULE=auto

Please add image description

2.Install Code Runner

Please add image description

Please add image description

Method 2:

god mod init go_1  //后面自己命名

The Buddha said that for people who are not destined to you, no matter how much you talk to them, it will be nonsense.
For people who are destined to you, your presence can awaken all their feelings.

Guess you like

Origin blog.csdn.net/qq_40893490/article/details/127720623