github.com/TIBCOSoftware/flogo-lib@v0.5.9/core/mapper/exprmapper/function/string/length/length.go (about)

     1  package length
     2  
     3  import (
     4  	"github.com/TIBCOSoftware/flogo-lib/core/mapper/exprmapper/expression/function"
     5  	"github.com/TIBCOSoftware/flogo-lib/logger"
     6  )
     7  
     8  var log = logger.GetLogger("length-function")
     9  
    10  type Length struct {
    11  }
    12  
    13  func init() {
    14  	function.Registry(&Length{})
    15  }
    16  
    17  func (s *Length) GetName() string {
    18  	return "length"
    19  }
    20  
    21  func (s *Length) GetCategory() string {
    22  	return "string"
    23  }
    24  
    25  func (s *Length) Eval(str string) int {
    26  	log.Debugf("Return the length of a string \"%s\"", str)
    27  	var l int
    28  	l = len(str)
    29  	log.Debugf("Done calculating the length %d", l)
    30  	return l
    31  }