Categorygithub.com/eric-jxl/go
module
1.7.0
Repository: https://github.com/eric-jxl/go.git
Documentation: pkg.go.dev

# README

Go

GitHub go.mod Go version (subdirectory of monorepo) build-go-binary

  • Based on go version 1.21.1 darwin/amd64
  • Golang Software Development Kit

go build

commandsUsage
-o指定输出的文件名,可以带上路径,例如 go build -o a/b/c
-i安装相应的包,编译+go install
-a更新全部已经是最新的包的,但是对标准包不适用
-n把需要执行的编译命令打印出来,但是不执行,这样就可以很容易的知道底层是如何运行的
-pn指定可以并行可运行的编译数目,默认是CPU数目
-race开启编译的时候自动检测数据竞争的情况,目前只支持64位的机器
-v打印出来我们正在编译的包名
-work打印出来编译时候的临时文件夹名称,并且如果已经存在的话就不要删除
-x打印出来执行的命令,其实就是和-n的结果类似,只是这个会执行
-ccflagsarg list 传递参数给5c, 6c, 8c 调用
-compilername 指定相应的编译器,gccgo还是gc
-gccgoflagsarg list 传递参数给gccgo编译连接调用
-gcflagsarg list 传递参数给5g, 6g, 8g 调用
-installsuffixsuffix 为了和默认的安装包区别开来,采用这个前缀来重新安装那些依赖的包,-race的时候默认已经是-installsuffix race,大家可以通过-n命令来验证
-ldflagsflag list 传递参数给5l, 6l, 8l 调用
-tagstag list 设置在编译的时候可以适配的那些tag,详细的tag限制参考里面的 Build Constraints

go build 移除路径信息

CGO_ENABLED=0 go build -v -a -ldflags '-s -w' \
-gcflags="all=-trimpath=${PWD}" \
-asmflags="all=-trimpath=${PWD}" \
-o ./main main.go

Go代码编译成动态链接库

go build -buildmode=c-shared -o xx.so main.go

go clean 命令用于删除执行其他命令时产生的文件或目录

go mod

download   下载依赖包
edit  修改go.mod
init 初始化项目
vendor  将依赖复制到Vendor
tidy   拉取缺失模块,移除不用的模块
graph  打印依赖图

go bug

输入此命名后会直接打开默认浏览器,显示go的github页面进行bug报告,并会自动添加系统的信息。

//go:embed 打包静态资源


:coffee: :pizza: :basketball: :lemon: :apple: :orange:

鸣谢

特别感谢 JetBrains 为开源项目提供免费的 Goland 授权

Goland

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
用Go语言编写的自动压缩文件工具,将指定目录下的所有文件压缩成一个以"Eric_"为前缀的zip文件 An automatic file compression tool written in Go language that compresses all files in a specified directory into a zip file with the prefix "Eric_ */.