本文整理汇总了Golang中github.com/keybase/client/go/protocol.Time函数的典型用法代码示例。如果您正苦于以下问题:Golang Time函数的具体用法?Golang Time怎么用?Golang Time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Time函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetTimeAtPath
func (f JSONConfigFile) GetTimeAtPath(path string) keybase1.Time {
var ret keybase1.Time
s, _ := f.GetStringAtPath(path)
if len(s) == 0 {
return ret
}
u, err := strconv.ParseUint(s, 10, 64)
if err != nil {
return ret
}
ret = keybase1.Time(u)
return ret
}
示例2: 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
}
示例3: GetUpdateLastChecked
func (n NullConfiguration) GetUpdateLastChecked() keybase1.Time { return keybase1.Time(0) }
示例4: GetUpdatePreferenceSnoozeUntil
func (n NullConfiguration) GetUpdatePreferenceSnoozeUntil() keybase1.Time { return keybase1.Time(0) }
示例5: SetTimeAtPath
func (f *JSONConfigFile) SetTimeAtPath(path string, t keybase1.Time) error {
if t == keybase1.Time(0) {
return f.SetNullAtPath(path)
}
return f.SetStringAtPath(path, fmt.Sprintf("%d", t))
}
示例6: Insert
// Insert adds a user to the cache, keyed on UID.
func (c *Identify2Cache) Insert(up *keybase1.UserPlusKeys) error {
tmp := *up
copy := &tmp
copy.Uvv.CachedAt = keybase1.Time(time.Now().Unix())
return c.cache.Set(string(up.Uid), copy)
}
示例7: checkForUpdate
func (u *Updater) checkForUpdate(skipAssetDownload bool, force bool, requested bool) (update *keybase1.Update, err error) {
u.log.Info("Checking for update, current version is %s", u.options.Version)
if u.options.Force {
force = true
}
// Don't snooze if the user requested/wants an update (check) or we're forcing a check
if !requested && !force {
if snz := u.config.GetUpdatePreferenceSnoozeUntil(); snz > 0 {
snoozeUntil := keybase1.FromTime(snz)
if time.Now().Before(snoozeUntil) {
u.log.Info("Snoozing until %s", snoozeUntil)
return nil, nil
}
u.log.Debug("Snooze expired at %s", snoozeUntil)
// Clear out the snooze
u.config.SetUpdatePreferenceSnoozeUntil(keybase1.Time(0))
}
}
currentSemVersion, err := semver.Make(u.options.Version)
if err != nil {
return
}
u.log.Info("Using updater source: %s", u.source.Description())
u.log.Debug("Using options: %#v", u.options)
update, err = u.source.FindUpdate(u.options)
if err != nil || update == nil {
return
}
u.log.Info("Checking update with version: %s", update.Version)
updateSemVersion, err := semver.Make(update.Version)
if err != nil {
return
}
// Update instruction might be empty, if so we'll fill in with the default
// instructions for the platform.
if update.Instructions == nil || *update.Instructions == "" {
instructions, err := libkb.PlatformSpecificUpgradeInstructionsString()
if err != nil {
u.log.Errorf("Error trying to get update instructions: %s", err)
}
if instructions == "" {
instructions = u.options.DefaultInstructions
}
if instructions != "" {
u.log.Debug("Using default platform instructions: %s", instructions)
update.Instructions = &instructions
} else {
u.log.Debug("No instructions set for update")
}
}
if skipVersion := u.config.GetUpdatePreferenceSkip(); len(skipVersion) != 0 {
u.log.Debug("Update preference: skip %s", skipVersion)
if vers, err := semver.Make(skipVersion); err != nil {
u.log.Warning("Bad 'skipVersion' in config file: %q", skipVersion)
} else if vers.GE(updateSemVersion) {
u.log.Debug("Skipping updated version via config preference: %q", update.Version)
return nil, nil
}
}
if updateSemVersion.EQ(currentSemVersion) {
// Versions are the same, we are up to date
u.log.Info("Update matches current version: %s = %s", updateSemVersion, currentSemVersion)
if !force {
update = nil
return
}
} else if updateSemVersion.LT(currentSemVersion) {
u.log.Info("Update is older version: %s < %s", updateSemVersion, currentSemVersion)
if !force {
update = nil
return
}
}
if !skipAssetDownload && update.Asset != nil {
downloadPath, _, dlerr := u.downloadAsset(*update.Asset)
if dlerr != nil {
err = dlerr
return
}
update.Asset.LocalPath = downloadPath
}
return
}
示例8: checkForUpdate
func (u *Updater) checkForUpdate(skipAssetDownload bool, force bool, requested bool) (update *keybase1.Update, err error) {
u.log.Info("Checking for update, current version is %s", u.options.Version)
if u.options.Force {
force = true
}
// Don't snooze if the user requested/wants an update (check) or we're forcing a check
if !requested && !force {
if snz := u.config.GetUpdatePreferenceSnoozeUntil(); snz > 0 {
snoozeUntil := keybase1.FromTime(snz)
if time.Now().Before(snoozeUntil) {
u.log.Info("Snoozing until %s", snoozeUntil)
return nil, nil
}
u.log.Debug("Snooze expired at %s", snoozeUntil)
// Clear out the snooze
u.config.SetUpdatePreferenceSnoozeUntil(keybase1.Time(0))
}
}
currentSemVersion, err := semver.Make(u.options.Version)
if err != nil {
return
}
u.log.Info("Using updater source: %s", u.source.Description())
u.log.Debug("Using options: %#v", u.options)
update, err = u.source.FindUpdate(u.options)
if err != nil || update == nil {
return
}
u.log.Info("Checking update with version: %s", update.Version)
updateSemVersion, err := semver.Make(update.Version)
if err != nil {
return
}
if skp := u.config.GetUpdatePreferenceSkip(); len(skp) != 0 {
u.log.Debug("Update preference: skip %s", skp)
if vers, err := semver.Make(skp); err != nil {
u.log.Warning("Bad 'skipVersion' in config file: %q", skp)
} else if vers.GE(updateSemVersion) {
u.log.Debug("Skipping updated version via config preference: %q", update.Version)
return nil, nil
}
}
if updateSemVersion.EQ(currentSemVersion) {
// Versions are the same, we are up to date
u.log.Info("Update matches current version: %s = %s", updateSemVersion, currentSemVersion)
if !force {
update = nil
return
}
} else if updateSemVersion.LT(currentSemVersion) {
u.log.Info("Update is older version: %s < %s", updateSemVersion, currentSemVersion)
if !force {
update = nil
return
}
}
if !skipAssetDownload {
downloadPath, _, dlerr := u.downloadAsset(update.Asset)
if dlerr != nil {
err = dlerr
return
}
update.Asset.LocalPath = downloadPath
}
return
}