Skip to content

go-wonk/si

Repository files navigation

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.

Installation

go get -u github.com/go-wonk/si

Quick Start

  1. 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 to sisql.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages