本文整理匯總了Golang中github.com/tmaiaroto/discfg/config.ResponseObject.Item方法的典型用法代碼示例。如果您正苦於以下問題:Golang ResponseObject.Item方法的具體用法?Golang ResponseObject.Item怎麽用?Golang ResponseObject.Item使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/tmaiaroto/discfg/config.ResponseObject
的用法示例。
在下文中一共展示了ResponseObject.Item方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: DeleteKey
// DeleteKey deletes a key from a configuration
func DeleteKey(opts config.Options) config.ResponseObject {
resp := config.ResponseObject{
Action: "delete",
}
key, keyErr := formatKeyName(opts.Key)
if keyErr == nil {
opts.Key = key
storageResponse, err := storage.Delete(opts)
if err != nil {
resp.Error = err.Error()
resp.Message = "Error getting key value"
} else {
resp.Item = storageResponse
resp.Item.Key = opts.Key
resp.Item.Value = nil
resp.Item.Version = storageResponse.Version + 1
resp.PrevItem.Key = opts.Key
resp.PrevItem.Version = storageResponse.Version
resp.PrevItem.Value = storageResponse.Value
// log.Println(storageResponse)
}
} else {
resp.Error = NotEnoughArgsMsg
}
return resp
}
示例2: GetKey
// GetKey gets a key from a configuration
func GetKey(opts config.Options) config.ResponseObject {
resp := config.ResponseObject{
Action: "get",
}
key, keyErr := formatKeyName(opts.Key)
if keyErr == nil {
opts.Key = key
storageResponse, err := storage.Get(opts)
if err != nil {
resp.Error = err.Error()
} else {
resp.Item = storageResponse
}
} else {
resp.Error = keyErr.Error()
}
return resp
}