2019-03-03 14:12:22 -03:00
|
|
|
---
|
|
|
|
title: Environment Variables
|
|
|
|
---
|
|
|
|
|
|
|
|
Global environment variables to be passed down to all hooks and builds.
|
|
|
|
|
2021-05-31 01:53:57 +00:00
|
|
|
This is useful for `GO111MODULE`, for example. You can have your `.goreleaser.yml` file like the following:
|
2019-03-03 14:12:22 -03:00
|
|
|
|
|
|
|
```yaml
|
|
|
|
# .goreleaser.yml
|
|
|
|
env:
|
|
|
|
- GO111MODULE=on
|
2021-05-31 01:53:57 +00:00
|
|
|
- FOO={{ .Env.FOOBAR }}
|
|
|
|
- ENV_WITH_DEFAULT={{ if index .Env "ENV_WITH_DEFAULT" }}{{ .Env.ENV_WITH_DEFAULT }}{{ else }}default_value{{ end }}
|
2019-03-03 14:12:22 -03:00
|
|
|
before:
|
|
|
|
hooks:
|
2021-03-02 21:29:31 -03:00
|
|
|
- go mod tidy
|
2019-03-03 14:12:22 -03:00
|
|
|
builds:
|
|
|
|
- binary: program
|
|
|
|
```
|
|
|
|
|
2021-03-02 21:29:31 -03:00
|
|
|
This way, both `go mod tidy` and the underlying `go build` will have
|
2019-03-03 14:12:22 -03:00
|
|
|
`GO111MODULE` set to `on`.
|
|
|
|
|
2021-05-24 23:23:59 -03:00
|
|
|
The root `env` section also accepts templates.
|
|
|
|
|
|
|
|
!!! tip
|
|
|
|
Learn more about the [name template engine](/customization/templates/).
|