Go

fansichao 2021-10-23 16:16:35
Categories: Tags:

开发环境配置

.bash_profile配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 配置 $GOPATH/bin 可以直接使用 bin/xxx 命令
export GOROOT=/usr/lib/golang/
export GOPATH=~/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin


# >>>>>>> Go Proxy 加速
# 启用 Go Modules 功能
go env -w GO111MODULE=on
# 配置 GOPROXY 环境变量,以下三选一
# 1. 七牛 CDN
go env -w GOPROXY=https://goproxy.cn,direct
# 2. 阿里云
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
# 3. 官方
# go env -w GOPROXY=https://goproxy.io,direct

GOROOT 目录介绍

$GOPATH 环境变量定义了 Go 工作区的路径。一般设置为 $HOME/go

$GOROOT 定义的是 Go 的代码,编译器和工具的区域。 一般设置为 /usr/lib/golang

1
2
3
4
5
6
GOPATH
.
├── bin 存放通过 go install 按照的命令
├── pkg 存储预编译目标文件的地方,以加速程序的后续编译.仅编译遇到问题需要处理删除
├── src 所有 .go 文件或源代码的位置
│   └── github.com

Resources

GO-社区 wiki

Go 国内加速镜像

https://geektutu.com/post/quick-go-gin.html

Golang爬虫全攻略
https://www.jianshu.com/p/4e53d4727152

Pholcus(幽灵蛛)是一款纯 Go 语言编写的支持分布式的高并发爬虫软件
https://github.com/henrylee2cn/pholcus

GO常见问题

cannot find main module; see ‘go help modules’

https://blog.csdn.net/mr_oldcold/article/details/100759488