• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang builder.GetStruct函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang builder.Register函数代码示例发布时间:2022-05-23
下一篇:
Golang builder.Extend函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap