I'm building Golang project on gitlab CI and I'd like to pass $CI_COMMIT_TAG value to compiler. With g++ it would be something like g++ -DCI_COMMIT_TAG=$CI_COMMIT_TAG .... Is there anything simillar for go build command?
Asked
Active
Viewed 116 times
1
Denis Sheremet
- 2,453
- 2
- 18
- 34
1 Answers
2
main.go
package main
var YOUR_VARIABLE = ""
func main() {}
Shell command: go build -ldflags "-X main.YOUR_VARIABLE=$your_variable" main.go
Jessé Catrinck
- 2,227
- 19
- 20