# README
si(storage interface)
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)
Installation
go get -u github.com/go-wonk/si
Quick Start
- 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
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
Versions
v0.2.1
sihttp
's struct and interface name changed.
v0.1.1
siwrap
package has been renamed tosisql
.
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Functions
DecodeJson read src with json bytes then decode it into dst.
DecodeJsonCopied read src with json bytes then decode it into dst.
EncodeJson encode src into json bytes then write to dst.
EncodeJsonCopied encode src into json bytes then write to dst.
No description provided by the author
ReadAll reads from r until EOF.
Deprecated WriteAll writes input to w.