Skip to content

Commit

Permalink
update go-build-add-ldflags.md
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaobinqt committed Dec 27, 2022
1 parent 1c78b90 commit 88eff99
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions content/posts/go/go-build-add-ldflags.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ lightgallery: true

toc: false

math:
enable: true
math: true
---

<!-- author: xiaobinqt -->
Expand All @@ -37,7 +36,7 @@ math:
<!-- https://www.xiaobinqt.cn -->


Go 在编译时可以添加一些额外的参数,这些参数可以用来添加版本信息
Go 在编译时可以添加一些额外的参数,这些参数可以用来添加如版本等信息

比如有以下的 t.go 文件源码:point_down:

Expand Down Expand Up @@ -82,6 +81,6 @@ go build -ldflags "-X 'main.version=1.0.0' -X 'main.buildTime=$(date +"%Y-%m-%d

![示例结果](https://cdn.xiaobinqt.cn/xiaobinqt.io/20220613/4d68fd3e1a534653a83c099a30079ea9.png?imageView2/0/q/75|watermark/2/text/eGlhb2JpbnF0/font/dmlqYXlh/fontsize/1000/fill/IzVDNUI1Qg==/dissolve/52/gravity/SouthEast/dx/15/dy/15 '示例结果')

可以看到,编译后的文件中包含了版本信息,比如版本号、编译时间、提交ID等
可以看到,编译后的文件中包含了版本信息,比如版本号、编译时间、提交 ID 等


0 comments on commit 88eff99

Please sign in to comment.