diff options
| author | Tamás Gulácsi <tgulacsi78+waterhouse@gmail.com> | 2013-01-05 23:06:44 +0100 |
|---|---|---|
| committer | Tamás Gulácsi <tgulacsi78+waterhouse@gmail.com> | 2013-01-05 23:06:44 +0100 |
| commit | 5d2a1e8d4845e7a7f1dccd962bb0ee6a5f9d6081 (patch) | |
| tree | 7fb36c1ab3b11e0e3267417c1ebbaf0ef5466a82 /weed-fs/src/pkg/util | |
| parent | 824371035109225128f8942b64a817838a7c0c25 (diff) | |
| download | seaweedfs-5d2a1e8d4845e7a7f1dccd962bb0ee6a5f9d6081.tar.xz seaweedfs-5d2a1e8d4845e7a7f1dccd962bb0ee6a5f9d6081.zip | |
add cmd/dump - a dumper
Walk needed to be added to NeedleMap and CompactMap, to be able to add WalkKeys and WalkValues to volume. This is needed for iterating through all the stored needles in a volume - this was dump's purpose.
Diffstat (limited to 'weed-fs/src/pkg/util')
| -rw-r--r-- | weed-fs/src/pkg/util/bytes.go | 53 | ||||
| -rw-r--r-- | weed-fs/src/pkg/util/parse.go | 20 | ||||
| -rw-r--r-- | weed-fs/src/pkg/util/post.go | 2 |
3 files changed, 37 insertions, 38 deletions
diff --git a/weed-fs/src/pkg/util/bytes.go b/weed-fs/src/pkg/util/bytes.go index 177da06db..6cc3d7018 100644 --- a/weed-fs/src/pkg/util/bytes.go +++ b/weed-fs/src/pkg/util/bytes.go @@ -1,34 +1,33 @@ package util -func BytesToUint64(b []byte)(v uint64){ - length := uint(len(b)) - for i :=uint(0);i<length-1;i++ { - v += uint64(b[i]) - v <<= 8 - } - v+=uint64(b[length-1]) - return +func BytesToUint64(b []byte) (v uint64) { + length := uint(len(b)) + for i := uint(0); i < length-1; i++ { + v += uint64(b[i]) + v <<= 8 + } + v += uint64(b[length-1]) + return } -func BytesToUint32(b []byte)(v uint32){ - length := uint(len(b)) - for i :=uint(0);i<length-1;i++ { - v += uint32(b[i]) - v <<= 8 - } - v+=uint32(b[length-1]) - return +func BytesToUint32(b []byte) (v uint32) { + length := uint(len(b)) + for i := uint(0); i < length-1; i++ { + v += uint32(b[i]) + v <<= 8 + } + v += uint32(b[length-1]) + return } -func Uint64toBytes(b []byte, v uint64){ - for i :=uint(0);i<8;i++ { - b[7-i] = byte(v>>(i*8)) - } +func Uint64toBytes(b []byte, v uint64) { + for i := uint(0); i < 8; i++ { + b[7-i] = byte(v >> (i * 8)) + } } -func Uint32toBytes(b []byte, v uint32){ - for i :=uint(0);i<4;i++ { - b[3-i] = byte(v>>(i*8)) - } +func Uint32toBytes(b []byte, v uint32) { + for i := uint(0); i < 4; i++ { + b[3-i] = byte(v >> (i * 8)) + } } -func Uint8toBytes(b []byte, v uint8){ - b[0] = byte(v) +func Uint8toBytes(b []byte, v uint8) { + b[0] = byte(v) } - diff --git a/weed-fs/src/pkg/util/parse.go b/weed-fs/src/pkg/util/parse.go index 6a4350e72..930da9522 100644 --- a/weed-fs/src/pkg/util/parse.go +++ b/weed-fs/src/pkg/util/parse.go @@ -1,16 +1,16 @@ package util import ( - "strconv" + "strconv" ) -func ParseInt(text string, defaultValue int) int{ - count, parseError := strconv.ParseUint(text,10,64) - if parseError!=nil { - if len(text)>0{ - return 0 - } - return defaultValue - } - return int(count) +func ParseInt(text string, defaultValue int) int { + count, parseError := strconv.ParseUint(text, 10, 64) + if parseError != nil { + if len(text) > 0 { + return 0 + } + return defaultValue + } + return int(count) } diff --git a/weed-fs/src/pkg/util/post.go b/weed-fs/src/pkg/util/post.go index f643faa6b..6e6ab0003 100644 --- a/weed-fs/src/pkg/util/post.go +++ b/weed-fs/src/pkg/util/post.go @@ -16,7 +16,7 @@ func Post(url string, values url.Values) ([]byte, error) { defer r.Body.Close() b, err := ioutil.ReadAll(r.Body) if err != nil { - log.Println("read post result from", url, err) + log.Println("read post result from", url, err) return nil, err } return b, nil |
