16 May 2025
Examples of syntax templates go – if -else conditional, env, printf function

Examples of syntax templates go – if -else conditional, env, printf function


This is an example of the syntax of GO template, what is done here:

  • Make $domain variable with an empty value.
  • Make $ns variables with values ​​derived NAMESPACE Environmental variable. So, we need to fill it first to make logic function. For example export NAMESPACE=staging.
  • Logic / IF-ELSE Conditional to check equality ( eq ) from $ns.
  • printf Function for a combination of string.
{{ $domain := "" }}
{{ $ns := env "NAMESPACE" -}}
{{ if eq $ns "staging" -}}
{{ $domain = printf ".%s.svc.cluster.local:2200" $ns }}
{{ else -}}
{{ $domain = printf ".%s.svc.cluster.local:2200" $ns }}
{{ end }}



Game Center

Game News

Review Film
Rumus Matematika
Anime Batch
Berita Terkini
Berita Terkini
Berita Terkini
Berita Terkini
review anime

Gaming Center