本文整理汇总了Golang中github.com/lann/builder.GetStruct函数的典型用法代码示例。如果您正苦于以下问题:Golang GetStruct函数的具体用法?Golang GetStruct怎么用?Golang GetStruct使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetStruct函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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")
}
开发者ID:nancyandrews,项目名称:MobileMainStreet,代码行数:9,代码来源:statement_test.go
示例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")
}
开发者ID:zenododobird,项目名称:horizon,代码行数:9,代码来源:statement_test.go
示例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)
}
}
开发者ID:zenododobird,项目名称:horizon,代码行数:8,代码来源:builder_test.go
示例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")
}
}
开发者ID:zenododobird,项目名称:horizon,代码行数:11,代码来源:builder_test.go
示例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)
}
}
开发者ID:zenododobird,项目名称:horizon,代码行数:20,代码来源:builder_test.go
示例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
}
开发者ID:denkhaus,项目名称:beamer,代码行数:22,代码来源:beamer.go
示例7: Equals
func (b simpleExprBuilder) Equals() int {
return builder.GetStruct(b).(simpleExpr).Equals()
}
开发者ID:zenododobird,项目名称:horizon,代码行数:3,代码来源:example_test.go
示例8: build
func (b FunctionBuilder) build() functionData {
return builder.GetStruct(b).(functionData)
}
开发者ID:Typeform,项目名称:goblitline,代码行数:3,代码来源:function.go
示例9: Build
func (b answersReqBuilder) Build() AnswerRequest {
return builder.GetStruct(b).(AnswerRequest)
}
开发者ID:fun-alex-alex2006hw,项目名称:stk,代码行数:3,代码来源:builders.go
示例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()
}
开发者ID:nancyandrews,项目名称:MobileMainStreet,代码行数:5,代码来源:update.go
示例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()
}
开发者ID:nancyandrews,项目名称:MobileMainStreet,代码行数:5,代码来源:update.go
示例12: Build
func (rb ruleBuilder) Build() Rule {
return builder.GetStruct(rb).(Rule)
}
开发者ID:joslinm,项目名称:validate,代码行数:3,代码来源:rule_builder.go
示例13: TestSetNil
func TestSetNil(t *testing.T) {
b := FooBuilder.I(nil)
builder.GetStruct(b)
}
开发者ID:zenododobird,项目名称:horizon,代码行数:4,代码来源:builder_test.go
示例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()
}
开发者ID:zenododobird,项目名称:horizon,代码行数:5,代码来源:insert.go
示例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()
}
开发者ID:zenododobird,项目名称:horizon,代码行数:5,代码来源:insert.go
示例16: Exec
// Exec builds and Execs the query with the Runner set by RunWith.
func (b SelectBuilder) Exec() (sql.Result, error) {
data := builder.GetStruct(b).(selectData)
return data.Exec()
}
开发者ID:zenododobird,项目名称:horizon,代码行数:5,代码来源:select.go
示例17: build
func (b ContainerBuilder) build() containerData {
return builder.GetStruct(b).(containerData)
}
开发者ID:Typeform,项目名称:goblitline,代码行数:3,代码来源:container.go
示例18: Query
// Query builds and Querys the query with the Runner set by RunWith.
func (b SelectBuilder) Query() (*sql.Rows, error) {
data := builder.GetStruct(b).(selectData)
return data.Query()
}
开发者ID:zenododobird,项目名称:horizon,代码行数:5,代码来源:select.go
示例19: ToSql
// ToSql builds the query into a SQL string and bound args.
func (b SelectBuilder) ToSql() (string, []interface{}, error) {
data := builder.GetStruct(b).(selectData)
return data.ToSql()
}
开发者ID:zenododobird,项目名称:horizon,代码行数:5,代码来源:select.go
示例20: QueryRow
// QueryRow builds and QueryRows the query with the Runner set by RunWith.
func (b SelectBuilder) QueryRow() RowScanner {
data := builder.GetStruct(b).(selectData)
return data.QueryRow()
}
开发者ID:zenododobird,项目名称:horizon,代码行数:5,代码来源:select.go
注:本文中的github.com/lann/builder.GetStruct函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论