From 66540cf1fcd2c3aee6f6787dfa32a6ae9a870f12 Mon Sep 17 00:00:00 2001 From: Cameron Moore Date: Fri, 23 Mar 2018 13:52:43 -0500 Subject: [PATCH] Go 1.10 support (#223) * Update Travis CI to use latest Go releases * Fix go vet issues for Go 1.10 Starting in Go 1.10, the `go test` command now automatically runs `go vet`. This commit fixes two issues flagged by vet that cause `go test` to fail. * Fix gofmt issue for Go 1.10 Go 1.10 introduced a small formatting change with comments in empty multiline slice definitions. This commit attempts to move the offending comment in such a way that all version of gofmt will agree on its location. * Remove go-vet from test.sh Starting in Go 1.10, the `go test` command automatically runs `go vet`, so we don't need to run `go vet` explicitly from within test.sh. Fixes #222 --- .travis.yml | 5 +++-- cmd/tomljson/main.go | 13 ++++++------- cmd/tomll/main.go | 17 ++++++++--------- query/parser_test.go | 6 +++--- test.sh | 3 --- 5 files changed, 20 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index ab2775d..c9fbf30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,9 @@ sudo: false language: go go: - - 1.8.5 - - 1.9.2 + - 1.8.x + - 1.9.x + - 1.10.x - tip matrix: allow_failures: diff --git a/cmd/tomljson/main.go b/cmd/tomljson/main.go index b2d6fc6..322315b 100644 --- a/cmd/tomljson/main.go +++ b/cmd/tomljson/main.go @@ -17,13 +17,12 @@ import ( func main() { flag.Usage = func() { - fmt.Fprintln(os.Stderr, `tomljson can be used in two ways: -Writing to STDIN and reading from STDOUT: - cat file.toml | tomljson > file.json - -Reading from a file name: - tomljson file.toml -`) + fmt.Fprintln(os.Stderr, "tomljson can be used in two ways:") + fmt.Fprintln(os.Stderr, "Writing to STDIN and reading from STDOUT:") + fmt.Fprintln(os.Stderr, " cat file.toml | tomljson > file.json") + fmt.Fprintln(os.Stderr, "") + fmt.Fprintln(os.Stderr, "Reading from a file name:") + fmt.Fprintln(os.Stderr, " tomljson file.toml") } flag.Parse() os.Exit(processMain(flag.Args(), os.Stdin, os.Stdout, os.Stderr)) diff --git a/cmd/tomll/main.go b/cmd/tomll/main.go index 36c7e37..93ab0c9 100644 --- a/cmd/tomll/main.go +++ b/cmd/tomll/main.go @@ -17,15 +17,14 @@ import ( func main() { flag.Usage = func() { - fmt.Fprintln(os.Stderr, `tomll can be used in two ways: -Writing to STDIN and reading from STDOUT: - cat file.toml | tomll > file.toml - -Reading and updating a list of files: - tomll a.toml b.toml c.toml - -When given a list of files, tomll will modify all files in place without asking. -`) + fmt.Fprintln(os.Stderr, "tomll can be used in two ways:") + fmt.Fprintln(os.Stderr, "Writing to STDIN and reading from STDOUT:") + fmt.Fprintln(os.Stderr, " cat file.toml | tomll > file.toml") + fmt.Fprintln(os.Stderr, "") + fmt.Fprintln(os.Stderr, "Reading and updating a list of files:") + fmt.Fprintln(os.Stderr, " tomll a.toml b.toml c.toml") + fmt.Fprintln(os.Stderr, "") + fmt.Fprintln(os.Stderr, "When given a list of files, tomll will modify all files in place without asking.") } flag.Parse() // read from stdin and print to stdout diff --git a/query/parser_test.go b/query/parser_test.go index 473896a..312f51a 100644 --- a/query/parser_test.go +++ b/query/parser_test.go @@ -2,12 +2,13 @@ package query import ( "fmt" - "github.com/pelletier/go-toml" "io/ioutil" "sort" "strings" "testing" "time" + + "github.com/pelletier/go-toml" ) type queryTestNode struct { @@ -406,8 +407,7 @@ func TestQueryFilterFn(t *testing.T) { assertQueryPositions(t, string(buff), "$..[?(float)]", - []interface{}{ - // no float values in document + []interface{}{ // no float values in document }) tv, _ := time.Parse(time.RFC3339, "1979-05-27T07:32:00Z") diff --git a/test.sh b/test.sh index a70a8b0..ba6adf3 100755 --- a/test.sh +++ b/test.sh @@ -23,9 +23,6 @@ function git_clone() { # Remove potential previous runs rm -rf src test_program_bin toml-test -# Run go vet -go vet ./... - go get github.com/pelletier/go-buffruneio go get github.com/davecgh/go-spew/spew go get gopkg.in/yaml.v2