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 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计