dongxiongshi9952 2017-04-19 14:21
浏览 104
已采纳

在beego中可以使用多个注释吗?

I have model like:

type Service struct {
    Id       uint64 
    Name     string 
    Secret   string 
    Disabled bool
}

And want to use annotations like form, valid and orm. And I can't find how I should declare these annotations. Should it be one or many? If many, what separator should I use?

  • 写回答

1条回答 默认 最新

  • douzhaolu4839 2017-04-19 14:31
    关注

    Quoting from reflect.StructTag:

    By convention, tag strings are a concatenation of optionally space-separated key:"value" pairs.

    So you may specify multiple key-value pairs separated by space, like:

    type Service struct {
        Id uint64 `form:"id" valid:"Range(1, 999)" orm:"auto"`
    }
    

    See more about tags in this answer: What are the use(s) for tags in Go?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器