Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lemonnekogh/go-ldflags-inject-demo
https://github.com/lemonnekogh/go-ldflags-inject-demo
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/lemonnekogh/go-ldflags-inject-demo
- Owner: LemonNekoGH
- Created: 2022-11-04T05:02:32.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-04T05:14:45.000Z (about 2 years ago)
- Last Synced: 2024-10-26T22:53:00.700Z (about 2 months ago)
- Language: Go
- Size: 0 Bytes
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-ldflags-configure
这是一个用 `-ldflags` 选项给变量注入值的例子
`main.go` 文件中的 `version` 是等待被注入的变量执行
```bash
$ go run main.go
```
结果
```bash
program version: 0.0.1
```执行
```bash
$ go run -ldflags "-X main.version=0.1.0" main.go
```
结果
```bash
program version: 0.1.0
```