Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document GOFLAGS #280

Merged
merged 1 commit into from
Dec 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,18 @@ This resulting configuration may then be installed onto Kubernetes clusters via:
kubectl apply -f release.yaml
```

### How can I set ldflags?

[Using `-ldflags`](https://blog.cloudflare.com/setting-go-variables-at-compile-time/)
is a common way to embed version info in go binaries. (In fact, [we do this for
`ko`](https://github.com/google/ko/blob/c2b862d468505dea36ed86e724ca3d190c0d462d/.goreleaser.yml#L15-L16).)
Unforunately, because `ko` wraps `go build`, it's not possible to use this
flag directly; however, you can use the `GOFLAGS` environment variable instead:

```
GOFLAGS="-ldflags=-X=main.version=1.2.3" ko publish .
```

### Why are my images all created in 1970?

In order to support [reproducible builds](https://reproducible-builds.org), `ko`
Expand Down