Fix gofmt and golint issues (#90)
This commit is contained in:
committed by
Thomas Pelletier
parent
e6271032cc
commit
bfe4a7e160
+2
-1
@@ -3,11 +3,12 @@ package main
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/pelletier/go-toml"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/pelletier/go-toml"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
+10
-9
@@ -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 @@ func processMain(files []string, defaultInput io.Reader, output io.Writer, error
|
||||
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 @@ func reader(r io.Reader) (string, error) {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 expectProcessMainResults(t *testing.T, input string, args []string, exitCod
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func TestProcessMainReadFromStdin(t *testing.T) {
|
||||
input := `
|
||||
[mytoml]
|
||||
@@ -54,7 +53,6 @@ func TestProcessMainReadFromFile(t *testing.T) {
|
||||
[mytoml]
|
||||
a = 42`
|
||||
|
||||
|
||||
tmpfile, err := ioutil.TempFile("", "example.toml")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -81,4 +79,4 @@ func TestProcessMainReadFromMissingFile(t *testing.T) {
|
||||
expectedError := `open /this/file/does/not/exist: no such file or directory
|
||||
`
|
||||
expectProcessMainResults(t, ``, []string{"/this/file/does/not/exist"}, -1, ``, expectedError)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user