本文整理汇总了Golang中github.com/zond/kcwraps/kol.DB.Set方法的典型用法代码示例。如果您正苦于以下问题:Golang DB.Set方法的具体用法?Golang DB.Set怎么用?Golang DB.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/zond/kcwraps/kol.DB
的用法示例。
在下文中一共展示了DB.Set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Set
func Set(d *kol.DB, at time.Duration) (err error) {
epoch := &Epoch{
Id: kol.Id(epochKey),
At: at,
}
err = d.Set(epoch)
return
}
示例2: ReliabilityDelta
func (self *Member) ReliabilityDelta(d *kol.DB, i int) (err error) {
user := &user.User{Id: self.UserId}
if err = d.Get(user); err != nil {
return
}
if i > 0 {
user.HeldDeadlines += i
} else {
user.MissedDeadlines -= i
}
if err = d.Set(user); err != nil {
return
}
return
}
示例3: allocate
func (self *Game) allocate(d *kol.DB, phase *Phase) (err error) {
members, err := self.Members(d)
if err != nil {
return
}
switch self.AllocationMethod {
case common.RandomString:
for memberIndex, nationIndex := range rand.Perm(len(members)) {
members[memberIndex].Nation = common.VariantMap[self.Variant].Nations[nationIndex]
}
case common.PreferencesString:
prefs := make([][]dip.Nation, len(members))
for index, member := range members {
prefs[index] = member.PreferredNations
}
for index, nation := range optimizePreferences(prefs) {
members[index].Nation = nation
}
default:
return fmt.Errorf("Unknown allocation method %v", self.AllocationMethod)
}
for index, _ := range members {
opts := dip.Options{}
if opts, err = phase.Options(members[index].Nation); err != nil {
return
}
members[index].Options = opts
if len(opts) == 0 {
members[index].Committed = true
members[index].NoOrders = true
} else {
members[index].Committed = false
members[index].NoOrders = false
}
if err = d.Set(&members[index]); err != nil {
return
}
}
return
}