douping3860 2014-01-22 11:36
浏览 29
已采纳

多路平等测试失败

So I have the following equality test in a go template

{{if eq .user.Role "Manager" "Admin"}}

which should work according to the docs and the 1.2 release notes, but I'm not having any luck

To make it more clear .user.Role "Manager" would work, or any equality test that involves only one argument. So something like {{if eq 1 1}} evaluates correctly, but {{if eq 1 2 1}} does not.

Error I get is 3: executing ".../index.html" at : wrong number of args for eq: want 2 got 3

  • 写回答

3条回答 默认 最新

  • doumibi6899 2014-01-23 05:07
    关注

    I can think of two possibilities. Either you aren't on version 1.2 (what does go version give?) or somewhere in the pipeline the eq function was replaced in the template's FuncMap. Unfortunately, it's not exported, so I can't think of a good way to know if the latter is the case. If you haven't replaced it, are you using a package that modifies the pipeline? If so, try the rendering without any packages and see if it works.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作