github.com/TIBCOSoftware/flogo-lib@v0.5.9/core/mapper/exprmapper/function/string/concat/concat.go (about) 1 package concat 2 3 import ( 4 "bytes" 5 "fmt" 6 7 "github.com/TIBCOSoftware/flogo-lib/core/mapper/exprmapper/expression/function" 8 "github.com/TIBCOSoftware/flogo-lib/logger" 9 ) 10 11 var log = logger.GetLogger("concat-function") 12 13 type Concat struct { 14 } 15 16 func init() { 17 function.Registry(&Concat{}) 18 } 19 20 func (s *Concat) GetName() string { 21 return "concat" 22 } 23 24 func (s *Concat) GetCategory() string { 25 return "string" 26 } 27 28 func (s *Concat) Eval(strs ...string) (string, error) { 29 log.Debugf("Start concat function with parameters %s", strs) 30 if len(strs) >= 2 { 31 var buffer bytes.Buffer 32 33 for _, v := range strs { 34 buffer.WriteString(v) 35 } 36 log.Debugf("Done concat function with result %s", buffer.String()) 37 return buffer.String(), nil 38 } 39 40 return "", fmt.Errorf("Concat function at least have 2 arguments") 41 }