当前位置:网站首页>Go语言学习
Go语言学习
2022-07-27 05:23:00 【lianyz1985】
设置Go环境变量
在/etc/profile或~/.zshrc中设置环境变量
export GOROOT=/users/lianyz/.go/current
export GOPATH=/users/lianyz/go
export GOPROXY=https://goproxy.cn
export GOPRIVATE=*.lianyz.com
GOPRIVATE用于私有仓库,以让GOPROXY跳过这些仓库,采用直连的方式
go mod 包管理
当在$GOPATH/src目录下创建目录并执行go mod init时,不需要输入模块名称,go会根据当前路径直接生成模块名
go mod tidy 下载需要的依赖并移除不需要的依赖
go mod vendor 将项目需要的依赖移动到项目的vendor目录下,可以用于将依赖也提交到代码仓库。
Makefile示例
export tag=v1.1
root:
export ROOT=github.com/cncamp/golang
.PHONY: root
build:
echo "building httpserver binary"
mkdir -p bin/amd64
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/amd64 .
release: build
echo "building httpserver container"
docker build -t lianyz/httpserver:${tag} .
push: release
echo "pushing lianyz/httpserver"
docker push lianyz/httpserver:${tag}
Dockerfile示例
FROM alpine
ENV MY_SERVICE_PORT=80
ENV MY_SERVICE_PORT1=80
ENV MY_SERVICE_PORT2=80
ENV MY_SERVICE_PORT3=80
LABEL multi.lable1="value1" multi.label2="value2" other="value3"
ADD bin/amd64/httpserver /httpserver
EXPOSE 80
ENTRYPOINT /httpserver
在GoLand中设置拼写检查规则文件
- 创建文件~/.lianyz.dic
- 在文件中增加单词,一个单词一行,如: lianyz
- 将文件添加至GoLand->Preferences->Editor->Proofreading->Spelling中的Dictionaries。
边栏推荐
猜你喜欢
随机推荐
Decorator functions and the use of class decorators
pycharm在虚拟环境下跑jupyter notebook问题记录
RAID详解与配置
LVM与磁盘配额
shell脚本之函数调用
Markdown文档常用字体及颜色设置
Vscode solves the problem of using stuck ipynb files when running
磁盘管理与文件系统
英语基础知识:非谓语使用规则上篇
LVM and disk quota
Installation, configuration and use of gradle
数据库命令
网络故障排查:Ping和Tracert命令
torch加载自定义模型的问题
DNS fault analysis optimization
shell--变量的运算
Shell script one click configuration lamp
关于过快S验证码的一些问题
系统安全与应用
PSI|CSI和ROC|AUC和KS -备忘录








