當前位置: 首頁>>代碼示例>>Golang>>正文


Golang builder.GetStruct函數代碼示例

本文整理匯總了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")
}
開發者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


注:本文中的github.com/lann/builder.GetStruct函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。