本文整理匯總了Golang中github.com/tmaiaroto/discfg/config.ResponseObject.CfgVersion方法的典型用法代碼示例。如果您正苦於以下問題:Golang ResponseObject.CfgVersion方法的具體用法?Golang ResponseObject.CfgVersion怎麽用?Golang ResponseObject.CfgVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/tmaiaroto/discfg/config.ResponseObject
的用法示例。
在下文中一共展示了ResponseObject.CfgVersion方法的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
}