Fix gofmt and golint issues (#90)
diff --git a/cmd/test_program.go b/cmd/test_program.go
index 971465e..5829344 100644
--- a/cmd/test_program.go
+++ b/cmd/test_program.go
@@ -3,11 +3,12 @@
import (
"encoding/json"
"fmt"
- "github.com/pelletier/go-toml"
"io/ioutil"
"log"
"os"
"time"
+
+ "github.com/pelletier/go-toml"
)
func main() {
diff --git a/cmd/tomljson/main.go b/cmd/tomljson/main.go
index 809f688..7e9dc46 100644
--- a/cmd/tomljson/main.go
+++ b/cmd/tomljson/main.go
@@ -1,12 +1,13 @@
package main
import (
- "github.com/pelletier/go-toml"
- "io"
- "os"
+ "encoding/json"
"flag"
"fmt"
- "encoding/json"
+ "io"
+ "os"
+
+ "github.com/pelletier/go-toml"
)
func main() {
@@ -40,12 +41,12 @@
printError(err, errorOutput)
return -1
}
- io.WriteString(output, s + "\n")
+ io.WriteString(output, s+"\n")
return 0
}
func printError(err error, output io.Writer) {
- io.WriteString(output, err.Error() + "\n")
+ io.WriteString(output, err.Error()+"\n")
}
func reader(r io.Reader) (string, error) {
@@ -53,14 +54,14 @@
if err != nil {
return "", err
}
- return mapToJson(tree)
+ return mapToJSON(tree)
}
-func mapToJson(tree *toml.TomlTree) (string, error) {
+func mapToJSON(tree *toml.TomlTree) (string, error) {
treeMap := tree.ToMap()
bytes, err := json.MarshalIndent(treeMap, "", " ")
if err != nil {
return "", err
}
return string(bytes[:]), nil
-}
\ No newline at end of file
+}
diff --git a/cmd/tomljson/main_test.go b/cmd/tomljson/main_test.go
index 6260b2b..0b4bdbb 100644
--- a/cmd/tomljson/main_test.go
+++ b/cmd/tomljson/main_test.go
@@ -1,11 +1,11 @@
package main
import (
- "testing"
- "strings"
"bytes"
- "os"
"io/ioutil"
+ "os"
+ "strings"
+ "testing"
)
func expectBufferEquality(t *testing.T, name string, buffer *bytes.Buffer, expected string) {
@@ -32,7 +32,6 @@
}
}
-
func TestProcessMainReadFromStdin(t *testing.T) {
input := `
[mytoml]
@@ -54,7 +53,6 @@
[mytoml]
a = 42`
-
tmpfile, err := ioutil.TempFile("", "example.toml")
if err != nil {
t.Fatal(err)
@@ -81,4 +79,4 @@
expectedError := `open /this/file/does/not/exist: no such file or directory
`
expectProcessMainResults(t, ``, []string{"/this/file/does/not/exist"}, -1, ``, expectedError)
-}
\ No newline at end of file
+}
diff --git a/tomltree_conversions.go b/tomltree_conversions.go
index bc6a967..c9c6f95 100644
--- a/tomltree_conversions.go
+++ b/tomltree_conversions.go
@@ -1,6 +1,7 @@
-// Tools to convert a TomlTree to different representations
package toml
+// Tools to convert a TomlTree to different representations
+
import (
"fmt"
"strconv"
@@ -126,7 +127,7 @@
for k, v := range t.values {
switch node := v.(type) {
case []*TomlTree:
- array := make([]interface{}, 0)
+ var array []interface{}
for _, item := range node {
array = append(array, item.ToMap())
}
diff --git a/tomltree_conversions_test.go b/tomltree_conversions_test.go
index ddea8c4..1822dcb 100644
--- a/tomltree_conversions_test.go
+++ b/tomltree_conversions_test.go
@@ -92,13 +92,12 @@
expected := map[string]interface{}{
"menu": map[string]interface{}{
"main": []interface{}{
- map[string]interface{}{"a": "menu 1", "b": "menu 2", },
- map[string]interface{}{"c": "menu 3", "d": "menu 4", },
+ map[string]interface{}{"a": "menu 1", "b": "menu 2"},
+ map[string]interface{}{"c": "menu 3", "d": "menu 4"},
},
},
}
treeMap := tree.ToMap()
-
testMaps(t, treeMap, expected)
}