github.com/wfusion/gofusion@v1.1.14/common/utils/gomonkey/dsl/behavior.go (about) 1 package dsl 2 3 type Behavior interface { 4 Apply() []Params 5 } 6 7 type ReturnBehavior struct { 8 rets []Params 9 params Params 10 } 11 12 func (this *ReturnBehavior) Apply() []Params { 13 this.rets = append(this.rets, this.params) 14 return this.rets 15 } 16 17 type RepeatBehavior struct { 18 rets []Params 19 behavior Behavior 20 times int 21 } 22 23 func (this *RepeatBehavior) Apply() []Params { 24 for i := 0; i < this.times; i++ { 25 this.rets = append(this.rets, this.behavior.Apply()[0]) 26 } 27 return this.rets 28 }