本文整理匯總了Golang中github.com/lann/builder.GetStruct函數的典型用法代碼示例。如果您正苦於以下問題:Golang GetStruct函數的具體用法?Golang GetStruct怎麽用?Golang GetStruct使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetStruct函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestRunWithDB
func TestRunWithDB(t *testing.T) {
db := &sql.DB{}
assert.NotPanics(t, func() {
builder.GetStruct(Select().RunWith(db))
builder.GetStruct(Insert("t").RunWith(db))
builder.GetStruct(Update("t").RunWith(db))
builder.GetStruct(Delete("t").RunWith(db))
}, "RunWith(*sql.DB) should not panic")
}
示例2: TestRunWithTx
func TestRunWithTx(t *testing.T) {
tx := &sql.Tx{}
assert.NotPanics(t, func() {
builder.GetStruct(Select().RunWith(tx))
builder.GetStruct(Insert("t").RunWith(tx))
builder.GetStruct(Update("t").RunWith(tx))
builder.GetStruct(Delete("t").RunWith(tx))
}, "RunWith(*sql.Tx) should not panic")
}
示例3: TestGetStruct
func TestGetStruct(t *testing.T) {
b := FooBuilder.X(1).Y(2).Add(3).Add(4)
s := builder.GetStruct(b).(Foo)
expected := Foo{X: 1, Y: 2, Add: []int{3, 4}}
if !reflect.DeepEqual(s, expected) {
t.Errorf("expected %v, got %v", expected, s)
}
}
示例4: TestSetInvalidNil
func TestSetInvalidNil(t *testing.T) {
var panicVal interface{}
func() {
defer func() { panicVal = recover() }()
b := builder.Set(FooBuilder, "X", nil)
builder.GetStruct(b)
}()
if panicVal == nil {
t.Errorf("expected panic, didn't")
}
}
示例5: TestUnregisteredBuilder
func TestUnregisteredBuilder(t *testing.T) {
b := unregBuilder{}.Add(1)
x, _ := builder.Get(b, "X")
expected := []interface{}{1}
if !reflect.DeepEqual(x.([]interface{}), expected) {
t.Errorf("expected %v, got %v", expected, x)
}
x = builder.GetMap(b)["X"]
expected = []interface{}{1}
if !reflect.DeepEqual(x.([]interface{}), expected) {
t.Errorf("expected %v, got %v", expected, x)
}
s := builder.GetStruct(b)
if s != nil {
t.Errorf("expected nil, got %v", s)
}
}
示例6: Run
//############################################################################
func (p beamerBuilder) Run() error {
ctx := builder.GetStruct(p).(common.BeamerCtx)
pipes := make([]pipe.Pipe, 0)
for _, t := range ctx.Tasks {
pip, err := t.Assemble(ctx)
if err != nil {
return err
}
pipes = append(pipes, pip)
}
script := pipe.Script(pipes...)
output, err := pipe.CombinedOutput(script)
if err != nil {
return err
}
applog.Infof("%s", output)
return nil
}
示例7: Equals
func (b simpleExprBuilder) Equals() int {
return builder.GetStruct(b).(simpleExpr).Equals()
}
示例8: build
func (b FunctionBuilder) build() functionData {
return builder.GetStruct(b).(functionData)
}
示例9: Build
func (b answersReqBuilder) Build() AnswerRequest {
return builder.GetStruct(b).(AnswerRequest)
}
示例10: ToSql
// ToSql builds the query into a SQL string and bound args.
func (b UpdateBuilder) ToSql() (string, []interface{}, error) {
data := builder.GetStruct(b).(updateData)
return data.ToSql()
}
示例11: Exec
// Exec builds and Execs the query with the Runner set by RunWith.
func (b UpdateBuilder) Exec() (sql.Result, error) {
data := builder.GetStruct(b).(updateData)
return data.Exec()
}
示例12: Build
func (rb ruleBuilder) Build() Rule {
return builder.GetStruct(rb).(Rule)
}
示例13: TestSetNil
func TestSetNil(t *testing.T) {
b := FooBuilder.I(nil)
builder.GetStruct(b)
}
示例14: Exec
// Exec builds and Execs the query with the Runner set by RunWith.
func (b InsertBuilder) Exec() (sql.Result, error) {
data := builder.GetStruct(b).(insertData)
return data.Exec()
}
示例15: QueryRow
// QueryRow builds and QueryRows the query with the Runner set by RunWith.
func (b InsertBuilder) QueryRow() RowScanner {
data := builder.GetStruct(b).(insertData)
return data.QueryRow()
}