判断

作者: 吴宪峰 | 来源:发表于2019-07-17 22:03 被阅读0次

判断 autoload[0] 只能是 yes 或 no

func AddOption(key, value string, autoload ...string) (db *gorm.DB) {
    var iAutoload = "yes"
    if len(autoload) > 0 {
        if !((autoload[0] != "yes") && (autoload[0] != "no")) {
            iAutoload = autoload[0]
        }
    }
    db = Database.Create(&Option{OptionName: key, OptionValue: value, Autoload: iAutoload})
    return
}

相关文章

网友评论

      本文标题:判断

      本文链接:https://www.haomeiwen.com/subject/brkhlctx.html