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运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 UE5#if WITH_EDITOR导致打包的功能不可用
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
  • ¥15 算法题:数的划分,用记忆化DFS做WA求调