本文整理汇总了Golang中github.com/keybase/client/go/protocol.UID.IsNil方法的典型用法代码示例。如果您正苦于以下问题:Golang UID.IsNil方法的具体用法?Golang UID.IsNil怎么用?Golang UID.IsNil使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/keybase/client/go/protocol.UID
的用法示例。
在下文中一共展示了UID.IsNil方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: LoadUserPlusKeys
func LoadUserPlusKeys(g *GlobalContext, uid keybase1.UID, cacheOK bool) (keybase1.UserPlusKeys, error) {
var up keybase1.UserPlusKeys
if uid.IsNil() {
return up, fmt.Errorf("Nil UID")
}
arg := NewLoadUserArg(g)
arg.UID = uid
arg.PublicKeyOptional = true
u, err := LoadUser(arg)
if err != nil {
return up, err
}
if u == nil {
return up, fmt.Errorf("Nil user, nil error from LoadUser")
}
// export user to UserPlusKeys
up.Uid = u.GetUID()
up.Username = u.GetNormalizedName().String()
if u.GetComputedKeyFamily() != nil {
up.DeviceKeys = u.GetComputedKeyFamily().ExportDeviceKeys()
}
return up, nil
}
示例2: RunSyncer
func RunSyncer(s Syncer, uid keybase1.UID, loggedIn bool, sr SessionReader) (err error) {
if uid.IsNil() {
return NotFoundError{"No UID given to syncer"}
}
// unnecessary for secret syncer, but possibly useful for tracker syncer.
s.Lock()
defer s.Unlock()
s.G().Log.Debug("+ Syncer.Load(%s)", uid)
defer func() {
s.G().Log.Debug("- Syncer.Load(%s) -> %s", uid, ErrToOk(err))
}()
if err = s.loadFromStorage(uid); err != nil {
return
}
if s.needsLogin() && !loggedIn {
s.G().Log.Debug("| Won't sync with server since we're not logged in")
return
}
if err = s.syncFromServer(uid, sr); err != nil {
return
}
if err = s.store(uid); err != nil {
return
}
return
}
示例3: lookupMerkleLeaf
func lookupMerkleLeaf(g *GlobalContext, uid keybase1.UID, local *User) (f *MerkleUserLeaf, err error) {
if uid.IsNil() {
err = fmt.Errorf("uid parameter for lookupMerkleLeaf empty")
return
}
q := NewHTTPArgs()
q.Add("uid", UIDArg(uid))
f, err = g.MerkleClient.LookupUser(q)
if err == nil && f == nil && local != nil {
err = fmt.Errorf("User not found in server Merkle tree")
}
return
}
示例4: LoadUserPlusKeys
func LoadUserPlusKeys(g *GlobalContext, uid keybase1.UID, cacheOK bool) (keybase1.UserPlusKeys, error) {
var up keybase1.UserPlusKeys
if uid.IsNil() {
return up, fmt.Errorf("Nil UID")
}
if cacheOK {
up, err := g.UserCache.Get(uid)
if err == nil {
return *up, nil
}
if err != nil {
// not going to bail on cache error, just log it:
if _, ok := err.(NotFoundError); !ok {
g.Log.Debug("UserCache Get error: %s", err)
}
}
}
arg := NewLoadUserArg(g)
arg.UID = uid
arg.PublicKeyOptional = true
u, err := LoadUser(arg)
if err != nil {
return up, err
}
if u == nil {
return up, fmt.Errorf("Nil user, nil error from LoadUser")
}
// export user to UserPlusKeys
up.Uid = u.GetUID()
up.Username = u.GetNormalizedName().String()
if u.GetComputedKeyFamily() != nil {
up.DeviceKeys = u.GetComputedKeyFamily().ExportDeviceKeys()
}
err = g.UserCache.Insert(&up)
if err != nil {
g.Log.Debug("UserCache Set error: %s", err)
}
return up, nil
}
示例5: LoadUserPlusKeys
func LoadUserPlusKeys(g *GlobalContext, uid keybase1.UID) (keybase1.UserPlusKeys, error) {
var up keybase1.UserPlusKeys
if uid.IsNil() {
return up, fmt.Errorf("Nil UID")
}
arg := NewLoadUserArg(g)
arg.UID = uid
arg.PublicKeyOptional = true
u, err := LoadUser(arg)
if err != nil {
return up, err
}
if u == nil {
return up, fmt.Errorf("Nil user, nil error from LoadUser")
}
return u.ExportToUserPlusKeys(keybase1.Time(0)), nil
}
示例6: loadThem
func (e *UntrackEngine) loadThem() (them *libkb.User, remoteLink, localLink *libkb.TrackChainLink, err error) {
var rLink *libkb.TrackChainLink
trackMap := e.arg.Me.IDTable().GetTrackMap()
if links, ok := trackMap[e.arg.Username]; ok && (len(links) > 0) {
rLink = links[len(links)-1]
}
var uid keybase1.UID
uidTrusted := false
if rLink != nil {
if uid, err = rLink.GetTrackedUID(); err != nil {
return
}
uidTrusted = true
}
if uid.IsNil() {
res := libkb.ResolveUID(e.arg.Username)
if err = res.GetError(); err != nil {
return
}
// This is an untrusted uid.
uid = res.GetUID()
if uid.IsNil() {
err = libkb.NewUntrackError("Could not resolve uid for @%s", e.arg.Username)
return
}
}
lLink, err := libkb.LocalTrackChainLinkFor(e.arg.Me.GetUID(), uid, e.G())
if err != nil {
return
}
if rLink == nil && lLink == nil {
err = libkb.NewUntrackError("You are not tracking %s", e.arg.Username)
return
}
if !uidTrusted {
if lLink == nil {
err = libkb.NewUntrackError("Could not verify resolved uid for @%s", e.arg.Username)
return
}
var trackedUsername string
trackedUsername, err = lLink.GetTrackedUsername()
if err != nil {
return
}
if e.arg.Username != trackedUsername {
err = libkb.NewUntrackError("Username mismatch: expected @%s, got @%s", e.arg.Username, trackedUsername)
return
}
uidTrusted = true
}
them = libkb.NewUserThin(e.arg.Username, uid)
remoteLink = rLink
localLink = lLink
return
}