Skip to content

Commit

Permalink
Fix by gofumpt.
Browse files Browse the repository at this point in the history
And module update.
  • Loading branch information
noborus committed Sep 1, 2019
1 parent 9854bdf commit af7cd9f
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 29 deletions.
1 change: 0 additions & 1 deletion _example/import/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ func main() {
if err != nil {
log.Fatal(err)
}

}
1 change: 1 addition & 0 deletions _example/quotecsv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func (w *QuoteWrite) WriteRow(values []interface{}, columns []string) error {
_, err := w.writer.Write([]byte(strings.Join(qColumns, ",") + "\n"))
return err
}

func (w *QuoteWrite) PostWrite() error {
return nil
}
Expand Down
13 changes: 7 additions & 6 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Ken,Thompson,ken
// }
//]
}

func ExampleSliceImporter() {
data := []struct {
id int
Expand All @@ -114,9 +115,9 @@ func ExampleSliceImporter() {
log.Fatal(err)
}
// Output:
//Henry,3
//Alice,2
//Bod,1
// Henry,3
// Alice,2
// Bod,1
}

func ExampleSliceWriter() {
Expand Down Expand Up @@ -208,7 +209,7 @@ func ExampleBufferImporter() {
log.Fatal(err)
}
// Output:
//Sarah Carpenter female ACCUSAGE
//Perez Atkinson male JOVIOLD
//Valeria Potts female EXOZENT
// Sarah Carpenter female ACCUSAGE
// Perez Atkinson male JOVIOLD
// Valeria Potts female EXOZENT
}
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/mattn/go-sqlite3 v1.11.0
github.com/noborus/tbln v0.0.1
github.com/olekukonko/tablewriter v0.0.1
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a // indirect
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472
golang.org/x/sys v0.0.0-20190830142957-1e83adbbebd0 // indirect
google.golang.org/appengine v1.6.2 // indirect
)
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 h1:58fnuSXlxZmFdJyvtTFVmV
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190618222545-ea8f1a30c443 h1:IcSOAf4PyMp3U3XbIEj1/xJ2BjNN2jWv7JoyOsMxXUU=
golang.org/x/crypto v0.0.0-20190618222545-ea8f1a30c443/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 h1:Gv7RPwsi3eZ2Fgewe3CBsuOebPwO27PoXzRpJPsvSSM=
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
Expand All @@ -63,13 +63,15 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190618155005-516e3c20635f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190830142957-1e83adbbebd0 h1:7z820YPX9pxWR59qM7BE5+fglp4D/mKqAwCvGt11b+8=
golang.org/x/sys v0.0.0-20190830142957-1e83adbbebd0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3I=
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.2 h1:j8RI1yW0SkI+paT6uGwMlrMI/6zwYA6/CFil8rxOzGI=
google.golang.org/appengine v1.6.2/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
3 changes: 1 addition & 2 deletions importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func TableNames(parsedQuery []string) (map[string]string, []int) {
}
if !isSQLKeyWords(w) {
tables[w] = w
tableIdx = append(tableIdx,i)
tableIdx = append(tableIdx, i)
}
}
frontFlag = false
Expand Down Expand Up @@ -194,7 +194,6 @@ func ImportFile(db *DB, fileName string, readOpts *ReadOpts) (string, error) {
debug.Printf("EOF reached before argument number of rows")
}
columnTypes, err := reader.Types()

if err != nil {
if err != io.EOF {
return tableName, err
Expand Down
16 changes: 10 additions & 6 deletions importer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ func TestImporter_Import(t *testing.T) {

func Test_listTable(t *testing.T) {
tests := []struct {
name string
query string
wantTbl map[string]string
wantIdx []int
name string
query string
wantTbl map[string]string
wantIdx []int
}{
{
name: "noTable",
Expand All @@ -103,13 +103,13 @@ func Test_listTable(t *testing.T) {
{
name: "testTable",
query: "SELECT * FROM test;",
wantTbl: map[string]string{"test" : "test"},
wantTbl: map[string]string{"test": "test"},
wantIdx: []int{6},
},
{
name: "testJoin",
query: "SELECT test.a FROM test LEFT JOIN test2 ON (test.b = test2.b);",
wantTbl: map[string]string{"test" : "test", "test2" : "test2"},
wantTbl: map[string]string{"test": "test", "test2": "test2"},
wantIdx: []int{6, 12},
},
}
Expand Down Expand Up @@ -177,6 +177,7 @@ func newDBTestSqlite3() *DB {
}
return db
}

func newDBTestPostgres() *DB {
db, err := Connect("postgres", "dbname=trdsql_test")
if err != nil {
Expand All @@ -188,6 +189,7 @@ func newDBTestPostgres() *DB {
}
return db
}

func newDBTestMysql() *DB {
db, err := Connect("mysql", "root@/trdsql_test")
if err != nil {
Expand All @@ -199,11 +201,13 @@ func newDBTestMysql() *DB {
}
return db
}

func csvReadOpts() *ReadOpts {
opts := NewReadOpts()
opts.InFormat = CSV
return opts
}

func TestImportFile(t *testing.T) {
type args struct {
db *DB
Expand Down
2 changes: 0 additions & 2 deletions input_csv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ func TestCsvIndefiniteInputFile(t *testing.T) {
if len(list) != 2 {
t.Error(`invalid column`)
}

}

func TestCsvIndefiniteInputFile2(t *testing.T) {
Expand Down Expand Up @@ -206,5 +205,4 @@ func TestCsvIndefiniteInputFile3(t *testing.T) {
if len(list) != 4 {
t.Errorf("invalid column got = %d", len(list))
}

}
1 change: 1 addition & 0 deletions input_slice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func TestNewSliceReader(t *testing.T) {
})
}
}

func TestNewMapSliceReader(t *testing.T) {
type args struct {
tableName string
Expand Down
2 changes: 0 additions & 2 deletions trdsql_json1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func TestJSONIndefiniteInputFile(t *testing.T) {
if len(list) != 2 {
t.Error(`invalid column`)
}

}

func TestJSONIndefiniteInputFile2(t *testing.T) {
Expand Down Expand Up @@ -64,5 +63,4 @@ func TestJSONIndefiniteInputFile3(t *testing.T) {
if len(list) != 4 {
t.Error(`invalid column`)
}

}
8 changes: 4 additions & 4 deletions trdsql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func setDefaultTRDSQL(outStream io.Writer) *TRDSQL {
}

func TestCSVRun(t *testing.T) {
var testCSV = [][]string{
testCSV := [][]string{
{"test.csv", "1,Orange\n2,Melon\n3,Apple\n"},
{"testcsv", "aaaaaaaa\nbbbbbbbb\ncccccccc\n"},
{"abc.csv", "a1\na2\n"},
Expand All @@ -194,7 +194,7 @@ func TestCSVRun(t *testing.T) {
}

func TestLTSVRun(t *testing.T) {
var testLTSV = [][]string{
testLTSV := [][]string{
{"test.ltsv", "1,Orange,50\n2,Melon,500\n3,Apple,100\n"},
{"apache.ltsv", "[28/Feb/2013:12:00:00 +0900],192.168.0.1,GET /list HTTP/1.1,200,5316,-,Mozilla/5.0,9789,1,-,-,-\n[28/Feb/2013:12:00:00 +0900],172.16.0.12,GET /list HTTP/1.1,200,5316,-,Mozilla/5.0,9789,1,-,-,-\n"},
}
Expand All @@ -214,7 +214,7 @@ func TestLTSVRun(t *testing.T) {
}

func TestJSONRun(t *testing.T) {
var testJSON = [][]string{
testJSON := [][]string{
{"test.json", "1,Orange\n2,Melon\n3,Apple\n"},
{"test2.json", "1,Orange\n2,Melon\n3,Apple\n"},
}
Expand All @@ -235,7 +235,7 @@ func TestJSONRun(t *testing.T) {
}

func TestTBLNRun(t *testing.T) {
var testTBLN = [][]string{
testTBLN := [][]string{
{"test.tbln", "1,Bob\n2,Alice\n"},
{"test2.tbln", "1,Orange\n2,Melon\n3,Apple\n"},
}
Expand Down

0 comments on commit af7cd9f

Please sign in to comment.