si
is a collection of wrappers that aims to ease reading/writing data from/to repositories. It is mostly a client side library and the following repositories or communication protocols will be supported from standard or non-standard packages.
- file
- tcp
- sql
- http
- websocket (gorilla)
- kafka (sarama)
- elasticsearch (go-elasticsearch)
- ftp (jlaffaye)
go get -u github.com/go-wonk/si
- sql
connStr := "host=testpghost port=5432 user=test password=test123 dbname=testdb sslmode=disable connect_timeout=60"
driver := "postgres"
db, _ := sql.Open(driver, connStr)
sqldb := sisql.NewSqlDB(db).WithTagKey("si")
type BoolTest struct {
Nil string `json:"nil" si:"nil"`
True_1 bool `json:"true_1" si:"true_1"`
True_2 bool `json:"true_2" si:"true_2"`
False_1 bool `json:"false_1" si:"false_1"`
False_2 bool `json:"false_2" si:"false_2"`
Ignore_3 string `si:"-"`
}
query := `
select null as nil,
null as true_1, '1' as true_2,
0 as false_1, '0' as false_2
union all
select null as nil,
1 as true_1, '1' as true_2,
0 as false_1, '0' as false_2
`
m := []BoolTest{}
_, err := sqldb.QueryStructs(query, &m)
Test flags include the following.
ONLINE_TEST
LONG_TEST
ONLINE_TEST=1 LONG_TEST=1 go test ./...
ONLINE_TEST=1 go test -run SKIP -bench . -benchtime 100x -benchmem
sihttp
's struct and interface name changed.
siwrap
package has been renamed tosisql
.