1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-22 04:08:49 +02:00
Jo 24347358e9
feat: add map and indexOrDefault template functions (#4317)
Add a new function `map` to template functions.

`map` creates a map from a list of pairs of key values, then you can
convert a key to a value using `.Get`. This simplifies writing
key-mapping templates. For example, the defaule `archives.name_template`

```yaml
name_template: >-
    {{ .ProjectName }}_
    {{- title .Os }}_
    {{- if eq .Arch "amd64" }}x86_64
    {{- else if eq .Arch "386" }}i386
    {{- else }}{{ .Arch }}{{ end }}
    {{- if .Arm }}v{{ .Arm }}{{ end }}
```

becomes

```yaml
name_template: >-
  {{ $arch := map "amd64" "x86_64" "386" "i386" -}}
  {{ .ProjectName }}_
  {{- title .OS }}_
  {{- $arch.Get .Arch .Arch }}
  {{- if .Arm }}v{{ .Arm }}{{ end }}
```

---------

Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2023-09-20 16:03:46 -03:00
..
2023-09-04 14:12:01 +00:00
2023-07-30 02:34:05 +00:00
2023-07-06 16:51:23 +00:00
2023-07-25 07:57:54 -03:00
2023-07-06 16:51:23 +00:00
2023-09-04 14:12:01 +00:00
2023-07-31 09:40:35 -03:00
2023-09-19 00:31:05 +00:00
2023-05-27 00:16:07 -03:00
2023-09-04 14:12:01 +00:00
2023-09-04 14:12:01 +00:00
2023-07-26 11:32:37 -03:00
2023-08-08 22:43:09 -03:00
2023-07-27 01:19:45 +00:00
2023-04-30 00:02:38 +00:00
2023-07-06 16:51:23 +00:00
2023-09-15 01:06:58 +00:00
2023-07-30 02:34:05 +00:00
2023-09-04 14:12:01 +00:00