with_ldflags

command
v0.5.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

go build 時に -ldflags を指定して内部の変数に外部から値を注入するサンプルです.

例:

$ go build -race -ldflags \
	" \
		-X main.version=$(git describe --tag --abbrev=0) \
		-X main.revision=$(git rev-list -1 HEAD) \
		-X main.build=$(git describe --tags) \
	"
$ go run  -race -ldflags \
	" \
		-X main.version=$(git describe --tag --abbrev=0) \
		-X main.revision=$(git rev-list -1 HEAD) \
		-X main.build=$(git describe --tags) \
	" .

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL