本文整理匯總了Golang中github.com/keybase/go-jsonw.Wrapper.UnmarshalAgain方法的典型用法代碼示例。如果您正苦於以下問題:Golang Wrapper.UnmarshalAgain方法的具體用法?Golang Wrapper.UnmarshalAgain怎麽用?Golang Wrapper.UnmarshalAgain使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/keybase/go-jsonw.Wrapper
的用法示例。
在下文中一共展示了Wrapper.UnmarshalAgain方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetMerkleTriple
func GetMerkleTriple(jw *jsonw.Wrapper) (ret *MerkleTriple, err error) {
var tmp MerkleTriple
if err = jw.UnmarshalAgain(&tmp); err != nil {
ret = &tmp
}
return ret, err
}
示例2: checkAppStatusFromJSONWrapper
func (a *InternalAPIEngine) checkAppStatusFromJSONWrapper(arg APIArg, jw *jsonw.Wrapper) (*AppStatus, error) {
var ast AppStatus
if err := jw.UnmarshalAgain(&ast); err != nil {
return nil, err
}
return &ast, a.checkAppStatus(arg, &ast)
}
示例3: ParseDevice
func ParseDevice(jw *jsonw.Wrapper) (ret *Device, err error) {
var obj Device
if err = jw.UnmarshalAgain(&obj); err == nil {
ret = &obj
}
return
}
示例4: ParseDevice
func ParseDevice(jw *jsonw.Wrapper, t time.Time) (ret *Device, err error) {
var obj Device
if err = jw.UnmarshalAgain(&obj); err == nil {
ret = &obj
ret.CTime = keybase1.ToTime(t)
ret.MTime = keybase1.ToTime(t)
}
return
}
示例5: ParseKeyFamily
// ParseKeyFamily takes as input a dictionary from a JSON file and returns
// a parsed version for manipulation in the program.
func ParseKeyFamily(jw *jsonw.Wrapper) (ret *KeyFamily, err error) {
G.Log.Debug("+ ParseKeyFamily")
defer func() {
G.Log.Debug("- ParseKeyFamily -> %s", ErrToOk(err))
}()
if jw == nil || jw.IsNil() {
err = KeyFamilyError{"nil record from server"}
return
}
kf := KeyFamily{
pgp2kid: make(map[PGPFingerprint]keybase1.KID),
kid2pgp: make(map[keybase1.KID]PGPFingerprint),
Contextified: NewContextified(G),
}
// Fill in AllKeys. Somewhat wasteful but probably faster than
// using Jsonw wrappers, and less error-prone.
var rkf RawKeyFamily
if err = jw.UnmarshalAgain(&rkf); err != nil {
return
}
kf.BundlesForTesting = rkf.AllBundles
// Parse the keys, and collect the PGP keys to map their fingerprints.
kf.AllKIDs = make(map[keybase1.KID]bool)
kf.PGPKeySets = make(map[keybase1.KID]*PGPKeySet)
kf.SingleKeys = make(map[keybase1.KID]GenericKey)
for _, bundle := range rkf.AllBundles {
newKey, err := ParseGenericKey(bundle)
if err != nil {
return nil, err
}
kid := newKey.GetKID()
if pgp, isPGP := newKey.(*PGPKeyBundle); isPGP {
ks, ok := kf.PGPKeySets[kid]
if !ok {
ks = &PGPKeySet{nil, make(map[string]*PGPKeyBundle)}
kf.PGPKeySets[kid] = ks
fp := pgp.GetFingerprint()
kf.pgp2kid[fp] = kid
kf.kid2pgp[kid] = fp
}
ks.addKey(pgp)
} else {
kf.SingleKeys[kid] = newKey
}
kf.AllKIDs[kid] = true
}
ret = &kf
return
}
示例6: UnpackComputedKeyInfos
func (c *ChainLink) UnpackComputedKeyInfos(jw *jsonw.Wrapper) (err error) {
var tmp ComputedKeyInfos
if jw == nil || jw.IsNil() {
return
}
if err = jw.UnmarshalAgain(&tmp); err == nil {
c.cki = &tmp
}
return
}
示例7: ImportUserConfigFromJSONWrapper
func ImportUserConfigFromJSONWrapper(jw *jsonw.Wrapper) (ret *UserConfig, err error) {
var tmp UserConfig
if jw == nil {
return
}
if err = jw.UnmarshalAgain(&tmp); err != nil {
return
}
if err = tmp.Import(); err != nil {
return
}
ret = &tmp
return
}
示例8: ParseKeyFamily
// ParseKeyFamily takes as input a dictionary from a JSON file and returns
// a parsed version for manipulation in the program.
func ParseKeyFamily(g *GlobalContext, jw *jsonw.Wrapper) (ret *KeyFamily, err error) {
defer g.Trace("ParseKeyFamily", func() error { return err })()
if jw == nil || jw.IsNil() {
err = KeyFamilyError{"nil record from server"}
return
}
kf := KeyFamily{
Contextified: NewContextified(g),
pgp2kid: make(map[PGPFingerprint]keybase1.KID),
kid2pgp: make(map[keybase1.KID]PGPFingerprint),
}
// Fill in AllKeys. Somewhat wasteful but probably faster than
// using Jsonw wrappers, and less error-prone.
var rkf RawKeyFamily
if err = jw.UnmarshalAgain(&rkf); err != nil {
return
}
kf.BundlesForTesting = rkf.AllBundles
// Parse the keys, and collect the PGP keys to map their fingerprints.
kf.AllKIDs = make(map[keybase1.KID]bool)
kf.PGPKeySets = make(map[keybase1.KID]*PGPKeySet)
kf.SingleKeys = make(map[keybase1.KID]GenericKey)
for i, bundle := range rkf.AllBundles {
newKey, err := ParseGenericKey(bundle)
// Some users have some historical bad keys, so no reason to crap
// out if we can't parse them, especially if there are others than
// can do just as well.
if err != nil {
g.Log.Notice("Failed to parse public key at position %d", i)
g.Log.Debug("Key parsing error: %s", err)
g.Log.Debug("Full key dump follows")
g.Log.Debug(bundle)
continue
}
kid := newKey.GetKID()
if pgp, isPGP := newKey.(*PGPKeyBundle); isPGP {
ks, ok := kf.PGPKeySets[kid]
if !ok {
ks = &PGPKeySet{NewContextified(g), nil, make(map[string]*PGPKeyBundle)}
kf.PGPKeySets[kid] = ks
fp := pgp.GetFingerprint()
kf.pgp2kid[fp] = kid
kf.kid2pgp[kid] = fp
}
ks.addKey(pgp)
} else {
kf.SingleKeys[kid] = newKey
}
kf.AllKIDs[kid] = true
}
ret = &kf
return
}