本文整理汇总了Golang中github.com/tmaiaroto/discfg/config.ResponseObject.CfgModifiedNanoseconds方法的典型用法代码示例。如果您正苦于以下问题:Golang ResponseObject.CfgModifiedNanoseconds方法的具体用法?Golang ResponseObject.CfgModifiedNanoseconds怎么用?Golang ResponseObject.CfgModifiedNanoseconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tmaiaroto/discfg/config.ResponseObject
的用法示例。
在下文中一共展示了ResponseObject.CfgModifiedNanoseconds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Info
// Info about the configuration including global version/state and modified time
func Info(opts config.Options) config.ResponseObject {
resp := config.ResponseObject{
Action: "info",
}
if opts.CfgName != "" {
// Just get the root key
opts.Key = "/"
storageResponse, err := storage.Get(opts)
if err != nil {
resp.Error = err.Error()
} else {
// Debating putting the item value on here... (allowing users to store values on the config or "root")
// resp.Item = storageResponse
// Set the configuration version and modified time on the response
// Item.CfgVersion and Item.CfgModifiedNanoseconds are not included in the JSON output
resp.CfgVersion = storageResponse.CfgVersion
resp.CfgModified = 0
resp.CfgModifiedNanoseconds = storageResponse.CfgModifiedNanoseconds
// Modified in seconds
resp.CfgModified = storageResponse.CfgModifiedNanoseconds / int64(time.Second)
// Modified parsed
modified := time.Unix(0, storageResponse.CfgModifiedNanoseconds)
resp.CfgModifiedParsed = modified.Format(time.RFC3339)
// Set information about the storage engine
resp.CfgStorage.InterfaceName = opts.StorageInterfaceName
resp.CfgStorage.Name = storage.Name(opts)
resp.CfgStorage.Options = storage.Options(opts)
// Get the status (only applicable for some storage interfaces, such as DynamoDB)
resp.CfgState, err = storage.ConfigState(opts)
if err != nil {
resp.Error = err.Error()
} else {
var buffer bytes.Buffer
buffer.WriteString(opts.CfgName)
if resp.CfgState != "" {
buffer.WriteString(" (")
buffer.WriteString(resp.CfgState)
buffer.WriteString(")")
}
buffer.WriteString(" version ")
buffer.WriteString(strconv.FormatInt(resp.CfgVersion, 10))
buffer.WriteString(" last modified ")
buffer.WriteString(modified.Format(time.RFC1123))
resp.Message = buffer.String()
buffer.Reset()
}
}
} else {
resp.Error = NotEnoughArgsMsg
}
return resp
}