gitlab.com/evatix-go/core@v1.3.55/coretests/AnyToBytes.go (about)

     1  package coretests
     2  
     3  func AnyToBytes(anyItem interface{}) []byte {
     4  	switch expectedAs := anyItem.(type) {
     5  	case []byte:
     6  		if expectedAs == nil {
     7  			return nil
     8  		}
     9  
    10  		return expectedAs
    11  	case *[]byte:
    12  		if expectedAs == nil || *expectedAs == nil {
    13  			return nil
    14  		}
    15  
    16  		return *expectedAs
    17  	default:
    18  		return nil
    19  	}
    20  }