aboutsummaryrefslogtreecommitdiff
path: root/weed/util
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2013-02-10 03:49:51 -0800
committerChris Lu <chris.lu@gmail.com>2013-02-10 03:49:51 -0800
commit5071f528f649f3f99336c7d491ceef4859e34744 (patch)
tree0c4bc8a286597cd79e22b1ce02cd9cd3b1c44602 /weed/util
parent55f2627fcf965c3765ad9b63878e9a22a59f4b55 (diff)
downloadseaweedfs-5071f528f649f3f99336c7d491ceef4859e34744.tar.xz
seaweedfs-5071f528f649f3f99336c7d491ceef4859e34744.zip
testing compilation with remove package
Diffstat (limited to 'weed/util')
-rw-r--r--weed/util/bytes.go33
-rw-r--r--weed/util/config.go128
-rw-r--r--weed/util/parse.go16
-rw-r--r--weed/util/post.go23
4 files changed, 0 insertions, 200 deletions
diff --git a/weed/util/bytes.go b/weed/util/bytes.go
deleted file mode 100644
index 6cc3d7018..000000000
--- a/weed/util/bytes.go
+++ /dev/null
@@ -1,33 +0,0 @@
-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 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 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)
-}
diff --git a/weed/util/config.go b/weed/util/config.go
deleted file mode 100644
index 6ac8a3a65..000000000
--- a/weed/util/config.go
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright 2011 Numerotron Inc.
-// Use of this source code is governed by an MIT-style license
-// that can be found in the LICENSE file.
-//
-// Developed at www.stathat.com by Patrick Crosby
-// Contact us on twitter with any questions: twitter.com/stat_hat
-
-// The jconfig package provides a simple, basic configuration file parser using JSON.
-package util
-
-import (
- "bytes"
- "encoding/json"
- "log"
- "os"
-)
-
-type Config struct {
- data map[string]interface{}
- filename string
-}
-
-func newConfig() *Config {
- result := new(Config)
- result.data = make(map[string]interface{})
- return result
-}
-
-// Loads config information from a JSON file
-func LoadConfig(filename string) *Config {
- result := newConfig()
- result.filename = filename
- err := result.parse()
- if err != nil {
- log.Fatalf("error loading config file %s: %s", filename, err)
- }
- return result
-}
-
-// Loads config information from a JSON string
-func LoadConfigString(s string) *Config {
- result := newConfig()
- err := json.Unmarshal([]byte(s), &result.data)
- if err != nil {
- log.Fatalf("error parsing config string %s: %s", s, err)
- }
- return result
-}
-
-func (c *Config) StringMerge(s string) {
- next := LoadConfigString(s)
- c.merge(next.data)
-}
-
-func (c *Config) LoadMerge(filename string) {
- next := LoadConfig(filename)
- c.merge(next.data)
-}
-
-func (c *Config) merge(ndata map[string]interface{}) {
- for k, v := range ndata {
- c.data[k] = v
- }
-}
-
-func (c *Config) parse() error {
- f, err := os.Open(c.filename)
- if err != nil {
- return err
- }
- defer f.Close()
- b := new(bytes.Buffer)
- _, err = b.ReadFrom(f)
- if err != nil {
- return err
- }
- err = json.Unmarshal(b.Bytes(), &c.data)
- if err != nil {
- return err
- }
-
- return nil
-}
-
-// Returns a string for the config variable key
-func (c *Config) GetString(key string) string {
- result, present := c.data[key]
- if !present {
- return ""
- }
- return result.(string)
-}
-
-// Returns an int for the config variable key
-func (c *Config) GetInt(key string) int {
- x, ok := c.data[key]
- if !ok {
- return -1
- }
- return int(x.(float64))
-}
-
-// Returns a float for the config variable key
-func (c *Config) GetFloat(key string) float64 {
- x, ok := c.data[key]
- if !ok {
- return -1
- }
- return x.(float64)
-}
-
-// Returns a bool for the config variable key
-func (c *Config) GetBool(key string) bool {
- x, ok := c.data[key]
- if !ok {
- return false
- }
- return x.(bool)
-}
-
-// Returns an array for the config variable key
-func (c *Config) GetArray(key string) []interface{} {
- result, present := c.data[key]
- if !present {
- return []interface{}(nil)
- }
- return result.([]interface{})
-}
diff --git a/weed/util/parse.go b/weed/util/parse.go
deleted file mode 100644
index 930da9522..000000000
--- a/weed/util/parse.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package util
-
-import (
- "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)
-}
diff --git a/weed/util/post.go b/weed/util/post.go
deleted file mode 100644
index 6e6ab0003..000000000
--- a/weed/util/post.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package util
-
-import (
- "io/ioutil"
- "log"
- "net/http"
- "net/url"
-)
-
-func Post(url string, values url.Values) ([]byte, error) {
- r, err := http.PostForm(url, values)
- if err != nil {
- log.Println("post to", url, err)
- return nil, err
- }
- defer r.Body.Close()
- b, err := ioutil.ReadAll(r.Body)
- if err != nil {
- log.Println("read post result from", url, err)
- return nil, err
- }
- return b, nil
-}