1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-03 13:11:48 +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-08-07 12:11:10 +00:00
2023-09-02 14:43:07 -03:00
2023-03-02 00:01:11 -03:00
2023-07-25 08:26:44 -03:00
2023-07-15 16:33:40 -03:00
2023-05-27 00:18:39 -03:00
2023-06-14 23:59:55 -03:00
2021-04-25 14:20:49 -03:00
2023-07-25 08:26:44 -03:00
2023-09-20 15:03:45 +00:00
2023-05-02 09:06:35 -03:00
2023-09-16 17:01:20 -03:00