# 设置cmd代理
set http_proxy=http://127.0.0.1:10809 set https_proxy=http://127.0.0.1:10809
set https_proxy=socks5://127.0.0.1:10808
set http_proxy=socks5://127.0.0.1:10808
# git
git config --global http.proxy socks5://127.0.0.1:1080 # Recover git global config: git config --global --unset http.proxy
# Golang:Delve版本太低无法Debug
Version of Delve is too old for this version of Go (maximum supported version 1.13, suppress this error with --check-go-version=false)
cause: dlv版本低
solution:直接去官网download https://github.com/go-delve/delve
替换你go目录下的 %GOPATH%\src\github.com\go-delve 这个目录即可
# Go程序报错1
X:\PycharmProjects\Project\TmpTest\GO_tmp\.vscode\Temp_Go\frist_go.go:7:6: main redeclared in this block previous declaration at X:\PycharmProjects\Project\TmpTest\GO_tmp\.vscode\Temp_Go\demo_1.go:13:6
exit status 2
Process exiting with code: 1
cause:同一个目录下面不能有个多 package main
solution:新建一个目录放置这个第二次调用main的代码
# Go程序报错2
fatal error: all goroutines are asleep - deadlock!
cause: 产生死锁,超出管道设定容量
solution:扩大设定管道的容量或者减少超过的管道
# Go程序报错3
package main import "fmt" func split(sum int) (x, y int) { x = sum * 4 / 9 y = sum - x return } func main() { fmt.Println("result is -->: ", split(17)) // 这个地方限制了仅有一个返回值 }
# command-line-arguments
.\compile19.go:12:24: multiple-value split() in single-value context
cause: 返回值有多个值
solution: 两种改法:
1) 直接把前面的字符型注释清空,仅保留后面有多个值反馈的函数
2) 把多值的函数内容单独赋值给变量,在输出位置单独应用每个变量
# Go程序报错4
Tips: 一个关于编译简写定义变量出错提示
syntax error: non-declaration statement outside function body
cause: 在全局变量使用了简写的变量定义和赋值
solution: 使用完整的定义方式
# 代码演示

1 package main 2
3 import ( 4 "fmt"
5 ) 6
7 var a int = 100 // 正确方式,不如编译会出错 8
9 // a :=100 这种简写仅能存在函数内,全局变量只能定义不能赋值
10
11 /** a:= 100 ,实际上是两条语句组成,如下: 12 var a int 13 a = 100 <--这个位置有赋值操作,所以定义在全局变量下会如下报错: 14 "syntax error: non-declaration statement outside function body" 15 **/
16
17 func main() { 18 b := 100 // 函数体内可以这么玩
19
20 fmt.Println(a) 21 fmt.Println(b) 22
23 }