OSDN Git Service

Merge pull request #201 from Bytom/v0.1
[bytom/vapor.git] / common / test_utils.go
diff --git a/common/test_utils.go b/common/test_utils.go
deleted file mode 100644 (file)
index 8346c14..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-package common
-
-import (
-       "encoding/json"
-       "fmt"
-       "io/ioutil"
-)
-
-// LoadJSON reads the given file and unmarshals its content.
-func LoadJSON(file string, val interface{}) error {
-       content, err := ioutil.ReadFile(file)
-       if err != nil {
-               return err
-       }
-       if err := json.Unmarshal(content, val); err != nil {
-               if syntaxerr, ok := err.(*json.SyntaxError); ok {
-                       line := findLine(content, syntaxerr.Offset)
-                       return fmt.Errorf("JSON syntax error at %v:%v: %v", file, line, err)
-               }
-               return fmt.Errorf("JSON unmarshal error in %v: %v", file, err)
-       }
-       return nil
-}
-
-// findLine returns the line number for the given offset into data.
-func findLine(data []byte, offset int64) (line int) {
-       line = 1
-       for i, r := range string(data) {
-               if int64(i) >= offset {
-                       return
-               }
-               if r == '\n' {
-                       line++
-               }
-       }
-       return
-}