本文整理匯總了Golang中github.com/luci/gae/service/datastore.Key.IntID方法的典型用法代碼示例。如果您正苦於以下問題:Golang Key.IntID方法的具體用法?Golang Key.IntID怎麽用?Golang Key.IntID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/luci/gae/service/datastore.Key
的用法示例。
在下文中一共展示了Key.IntID方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Valid
// Valid determines if a key is valid, according to a couple rules:
// - k is not nil
// - every token of k:
// - (if !allowSpecial) token's kind doesn't start with '__'
// - token's kind and appid are non-blank
// - token is not incomplete
// - all tokens have the same namespace and appid
func Valid(k ds.Key, allowSpecial bool, aid, ns string) bool {
if k == nil {
return false
}
if aid != k.AppID() || ns != k.Namespace() {
return false
}
for ; k != nil; k = k.Parent() {
if !allowSpecial && len(k.Kind()) >= 2 && k.Kind()[:2] == "__" {
return false
}
if k.Kind() == "" || k.AppID() == "" {
return false
}
if k.StringID() != "" && k.IntID() != 0 {
return false
}
if k.Parent() != nil {
if k.Parent().Incomplete() {
return false
}
if k.Parent().AppID() != k.AppID() || k.Parent().Namespace() != k.Namespace() {
return false
}
}
}
return true
}
示例2: Equal
// Equal returns true iff the two keys represent identical key values.
func Equal(a, b ds.Key) (ret bool) {
ret = (a.Kind() == b.Kind() &&
a.StringID() == b.StringID() &&
a.IntID() == b.IntID() &&
a.AppID() == b.AppID() &&
a.Namespace() == b.Namespace())
if !ret {
return
}
ap, bp := a.Parent(), b.Parent()
return (ap == nil && bp == nil) || Equal(ap, bp)
}
示例3: marshalDSKey
func marshalDSKey(b *bytes.Buffer, k ds.Key) {
if k.Parent() != nil {
marshalDSKey(b, k.Parent())
}
b.WriteByte('/')
b.WriteString(k.Kind())
b.WriteByte(',')
if k.StringID() != "" {
b.WriteString(k.StringID())
} else {
b.WriteString(strconv.FormatInt(k.IntID(), 10))
}
}
示例4: Incomplete
// Incomplete returns true iff k doesn't have an id yet.
func Incomplete(k ds.Key) bool {
return k != nil && k.StringID() == "" && k.IntID() == 0
}