Go:在模板中的 if 语句中使用环境变量

Go: Using environment variables in if statement in Template

下面是我用于 NGINX 配置的 Go 模板代码。在嵌套的 if 语句中,我试图检查环境变量 IS_CUSTOMER 的值是否等于 "true".

 {{ if eq .instanceName "apple" }}
       {{ if eq ({{envOrKey "IS_CUSTOMER"}}) "true" }}
         listen  127.0.0.1:{{.port}};
       {{else}}
         listen  {{.bindAddress}}:{{.port}};
       {{end}}
     {{else}}
         listen  {{.bindAddress}}:{{.port}};
     {{end}}
     listen  443 ssl ;

但是当我执行模板时,出现以下错误:

tenanttemplate.tmpl:13: unexpected \"{\" in operand" 

我浏览了 Go 模板的在线文档和 Stack overflow 上的一些其他答案,但没有帮助。

改变

 {{ if eq ({{envOrKey "IS_CUSTOMER"}}) "true" }}

 {{ if eq (envOrKey "IS_CUSTOMER") "true" }}