...

Source file src/github.com/go-task/slim-sprig/v3/reflect.go

Documentation: github.com/go-task/slim-sprig/v3

     1  package sprig
     2  
     3  import (
     4  	"fmt"
     5  	"reflect"
     6  )
     7  
     8  // typeIs returns true if the src is the type named in target.
     9  func typeIs(target string, src interface{}) bool {
    10  	return target == typeOf(src)
    11  }
    12  
    13  func typeIsLike(target string, src interface{}) bool {
    14  	t := typeOf(src)
    15  	return target == t || "*"+target == t
    16  }
    17  
    18  func typeOf(src interface{}) string {
    19  	return fmt.Sprintf("%T", src)
    20  }
    21  
    22  func kindIs(target string, src interface{}) bool {
    23  	return target == kindOf(src)
    24  }
    25  
    26  func kindOf(src interface{}) string {
    27  	return reflect.ValueOf(src).Kind().String()
    28  }
    29  

View as plain text