本文整理汇总了Golang中github.com/lann/builder.Register函数的典型用法代码示例。如果您正苦于以下问题:Golang Register函数的具体用法?Golang Register怎么用?Golang Register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Register函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Add
}
func (b simpleExprBuilder) Add(i int) simpleExprBuilder {
return builder.Append(b, "Adds", i).(simpleExprBuilder)
}
func (b simpleExprBuilder) Subtract(i int) simpleExprBuilder {
return builder.Append(b, "Subtracts", i).(simpleExprBuilder)
}
func (b simpleExprBuilder) Equals() int {
return builder.GetStruct(b).(simpleExpr).Equals()
}
// SimpleExprBuilder is an empty builder
var SimpleExprBuilder = builder.Register(simpleExprBuilder{}, simpleExpr{}).(simpleExprBuilder)
// End builder definition
func Example_basic() {
b := SimpleExprBuilder.Add(10).Subtract(3)
// Intermediate values can be reused
b2 := b.Multiplier(2)
b3 := b.Multiplier(3)
fmt.Println(b.Equals(), b2.Equals(), b3.Equals())
// Output:
// 7 14 21
}
开发者ID:zenododobird,项目名称:horizon,代码行数:31,代码来源:example_test.go
示例2: init
func init() {
builder.Register(InsertBuilder{}, insertData{})
}
开发者ID:zenododobird,项目名称:horizon,代码行数:3,代码来源:insert.go
示例3: Accepted
func (b searchReqBuilder) Accepted(flag bool) searchReqBuilder {
return builder.Set(b, "Accepted", flag).(searchReqBuilder)
}
func (b searchReqBuilder) Tags(tags []string) searchReqBuilder {
return builder.Set(b, "Tags", tags).(searchReqBuilder)
}
func (b searchReqBuilder) Build() SearchRequest {
return builder.GetStruct(b).(SearchRequest)
}
// Answer Request Builder
type answersReqBuilder builder.Builder
func (b answersReqBuilder) AddAnswerID(v int) answersReqBuilder {
return builder.Append(b, "AnswerIDS", v).(answersReqBuilder)
}
func (b answersReqBuilder) SiteID(v string) answersReqBuilder {
return builder.Set(b, "SiteID", v).(answersReqBuilder)
}
func (b answersReqBuilder) Build() AnswerRequest {
return builder.GetStruct(b).(AnswerRequest)
}
// Register Builders
var SearchRequestBuilder = builder.Register(searchReqBuilder{}, SearchRequest{}).(searchReqBuilder)
var AnswerRequestBuilder = builder.Register(answersReqBuilder{}, AnswerRequest{}).(answersReqBuilder)
开发者ID:fun-alex-alex2006hw,项目名称:stk,代码行数:30,代码来源:builders.go
示例4: init
func init() {
builder.Register(FunctionBuilder{}, functionData{})
}
开发者ID:Typeform,项目名称:goblitline,代码行数:3,代码来源:function.go
示例5: Y
return builder.Set(b, "X", i).(fooBuilder)
}
func (b fooBuilder) Y(i int) fooBuilder {
return builder.Set(b, "Y", i).(fooBuilder)
}
func (b fooBuilder) I(i interface{}) fooBuilder {
return builder.Set(b, "I", i).(fooBuilder)
}
func (b fooBuilder) Add(i int) fooBuilder {
return builder.Append(b, "Add", i).(fooBuilder)
}
var FooBuilder = builder.Register(fooBuilder{}, Foo{}).(fooBuilder)
type unregBuilder builder.Builder
func (b unregBuilder) Add(i int) unregBuilder {
return builder.Append(b, "X", i).(unregBuilder)
}
func assertInt(t *testing.T, b fooBuilder, key string, val int) {
v, ok := builder.Get(b, key)
if !ok {
t.Errorf("key %v not set", key)
return
}
i := v.(int)
if i != val {
开发者ID:zenododobird,项目名称:horizon,代码行数:31,代码来源:builder_test.go
示例6: init
func init() {
builder.Register(UpdateBuilder{}, updateData{})
}
开发者ID:nancyandrews,项目名称:MobileMainStreet,代码行数:3,代码来源:update.go
示例7: init
func init() {
builder.Register(DeleteBuilder{}, deleteData{})
}
开发者ID:nizsheanez,项目名称:squirrel,代码行数:3,代码来源:delete.go
示例8: init
func init() {
builder.Register(ContainerBuilder{}, containerData{})
}
开发者ID:Typeform,项目名称:goblitline,代码行数:3,代码来源:container.go
示例9: init
func init() {
builder.Register(SelectBuilder{}, selectData{})
}
开发者ID:zenododobird,项目名称:horizon,代码行数:3,代码来源:select.go
示例10: From
package tasks
import (
"github.com/lann/builder"
"gopkg.in/pipe.v2"
)
type copyCtx struct {
Source string
Dest string
}
var Copy = builder.Register(copyBuilder{}, copyCtx{}).(copyBuilder)
type copyBuilder builder.Builder
//############################################################################
func (b copyBuilder) From(src string) copyBuilder {
return builder.Set(b, "Source", src).(copyBuilder)
}
//############################################################################
func (b copyBuilder) To(dest string) copyBuilder {
return builder.Set(b, "Dest", dest).(copyBuilder)
}
//############################################################################
func (b copyBuilder) Descr(descr string) copyBuilder {
return builder.Set(b, "Description", descr).(copyBuilder)
}
开发者ID:denkhaus,项目名称:beamer,代码行数:30,代码来源:copy.go
示例11: BuildReply
return builder.GetStructLike(b, Message{}).(Message)
}
func (b jsonBuilder) BuildReply() Reply {
return builder.GetStructLike(b, Reply{}).(Reply)
}
func (b jsonBuilder) BuildCase() Case {
return builder.GetStructLike(b, Case{}).(Case)
}
func (b jsonBuilder) BuildDraft() Draft {
return builder.GetStructLike(b, Draft{}).(Draft)
}
func (b jsonBuilder) BuildNote() Note {
return builder.GetStructLike(b, Note{}).(Note)
}
func (b jsonBuilder) BuildCompany() Company {
return builder.GetStructLike(b, Company{}).(Company)
}
var CaseBuilder = builder.Register(jsonBuilder{}, Case{}).(jsonBuilder)
var MessageBuilder = builder.Register(jsonBuilder{}, Message{}).(jsonBuilder)
var ReplyBuilder = builder.Register(jsonBuilder{}, Reply{}).(jsonBuilder)
var CustomerBuilder = builder.Register(jsonBuilder{}, Customer{}).(jsonBuilder)
var DraftBuilder = builder.Register(jsonBuilder{}, Draft{}).(jsonBuilder)
var NoteBuilder = builder.Register(jsonBuilder{}, Note{}).(jsonBuilder)
var CompanyBuilder = builder.Register(jsonBuilder{}, Company{}).(jsonBuilder)
开发者ID:scotwells,项目名称:go-desk,代码行数:30,代码来源:json_builder.go
示例12: Mkdir
//############################################################################
func Mkdir(directory string) dirBuilder {
dir := builder.Register(dirBuilder{}, dirCtx{}).(dirBuilder)
return builder.Set(dir, "Directory", directory).(dirBuilder)
}
开发者ID:denkhaus,项目名称:beamer,代码行数:5,代码来源:mkdir.go
示例13: Before
ptr := &t
rb = builder.Set(rb, "After", ptr).(ruleBuilder)
rb = rb.updateTypeAccordingTo(ptr)
return rb
}
func (rb ruleBuilder) Before(t time.Time) ruleBuilder {
ptr := &t
rb = builder.Set(rb, "Before", ptr).(ruleBuilder)
rb = rb.updateTypeAccordingTo(ptr)
return rb
}
// callback
func (rb ruleBuilder) Custom(cb CustomCallback) ruleBuilder {
return builder.Append(rb, "Customs", cb).(ruleBuilder)
}
func (rb ruleBuilder) Alter(cb AlterCallback) ruleBuilder {
return builder.Append(rb, "Alters", cb).(ruleBuilder)
}
func (rb ruleBuilder) Prepare(cb PrepareCallback) ruleBuilder {
return builder.Append(rb, "Prepares", cb).(ruleBuilder)
}
// custom
func (rb ruleBuilder) Email() ruleBuilder {
return builder.Set(rb, "Regex", `(?i)[A-Z0-9._%+-][email protected](?:[A-Z0-9-]+\.)+[A-Z]{2,6}`).(ruleBuilder)
}
var RuleBuilder = builder.Register(ruleBuilder{}, Rule{}).(ruleBuilder)
var RB = RuleBuilder
开发者ID:joslinm,项目名称:validate,代码行数:30,代码来源:rule_builder.go
示例14: Sequence
package main
import (
"github.com/denkhaus/beamer/common"
"github.com/denkhaus/tcgl/applog"
"github.com/lann/builder"
"gopkg.in/pipe.v2"
)
type assembleFunc func() (pipe.Pipe, error)
var Beamer = builder.Register(beamerBuilder{}, common.BeamerCtx{}).(beamerBuilder)
type beamerBuilder builder.Builder
//############################################################################
func (p beamerBuilder) Sequence(ctxs ...common.TaskCtx) beamerBuilder {
b := p
for _, c := range ctxs {
b = builder.Append(b, "Tasks", c).(beamerBuilder)
}
return b
}
//############################################################################
func (p beamerBuilder) Set(key string, value interface{}) beamerBuilder {
m, ok := builder.Get(p, "KVStore")
if ok {
store := m.(map[string]interface{})
开发者ID:denkhaus,项目名称:beamer,代码行数:31,代码来源:beamer.go
示例15: init
func init() {
builder.Register(CaseBuilder{}, caseData{})
}
开发者ID:zenododobird,项目名称:horizon,代码行数:3,代码来源:case.go
注:本文中的github.com/lann/builder.Register函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论