mirror of https://github.com/perkeep/perkeep.git
client: case style
Change-Id: Ie72ebd19c09a863ba1be00fb35904daf867daa14
This commit is contained in:
parent
e2d0fd6aa3
commit
cc353f5748
|
@ -81,20 +81,20 @@ func (c *Client) EnumerateBlobsOpts(ch chan<- blobref.SizedBlobRef, opts Enumera
|
|||
return error("stat json parse error", err)
|
||||
}
|
||||
|
||||
blobs, ok := getJsonMapArray(json, "blobs")
|
||||
blobs, ok := getJSONMapArray(json, "blobs")
|
||||
if !ok {
|
||||
return error("response JSON didn't contain 'blobs' array", nil)
|
||||
}
|
||||
for _, v := range blobs {
|
||||
itemJson, ok := v.(map[string]interface{})
|
||||
itemJSON, ok := v.(map[string]interface{})
|
||||
if !ok {
|
||||
return error("item in 'blobs' was malformed", nil)
|
||||
}
|
||||
blobrefStr, ok := getJsonMapString(itemJson, "blobRef")
|
||||
blobrefStr, ok := getJSONMapString(itemJSON, "blobRef")
|
||||
if !ok {
|
||||
return error("item in 'blobs' was missing string 'blobRef'", nil)
|
||||
}
|
||||
size, ok := getJsonMapInt64(itemJson, "size")
|
||||
size, ok := getJSONMapInt64(itemJSON, "size")
|
||||
if !ok {
|
||||
return error("item in 'blobs' was missing numeric 'size'", nil)
|
||||
}
|
||||
|
@ -111,12 +111,12 @@ func (c *Client) EnumerateBlobsOpts(ch chan<- blobref.SizedBlobRef, opts Enumera
|
|||
}
|
||||
}
|
||||
|
||||
after, keepGoing = getJsonMapString(json, "continueAfter")
|
||||
after, keepGoing = getJSONMapString(json, "continueAfter")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getJsonMapString(m map[string]interface{}, key string) (string, bool) {
|
||||
func getJSONMapString(m map[string]interface{}, key string) (string, bool) {
|
||||
if v, ok := m[key]; ok {
|
||||
if s, ok := v.(string); ok {
|
||||
return s, true
|
||||
|
@ -125,7 +125,7 @@ func getJsonMapString(m map[string]interface{}, key string) (string, bool) {
|
|||
return "", false
|
||||
}
|
||||
|
||||
func getJsonMapInt64(m map[string]interface{}, key string) (int64, bool) {
|
||||
func getJSONMapInt64(m map[string]interface{}, key string) (int64, bool) {
|
||||
if v, ok := m[key]; ok {
|
||||
if n, ok := v.(float64); ok {
|
||||
return int64(n), true
|
||||
|
@ -134,7 +134,7 @@ func getJsonMapInt64(m map[string]interface{}, key string) (int64, bool) {
|
|||
return 0, false
|
||||
}
|
||||
|
||||
func getJsonMapArray(m map[string]interface{}, key string) ([]interface{}, bool) {
|
||||
func getJSONMapArray(m map[string]interface{}, key string) ([]interface{}, bool) {
|
||||
if v, ok := m[key]; ok {
|
||||
if a, ok := v.([]interface{}); ok {
|
||||
return a, true
|
||||
|
|
Loading…
Reference in New Issue