gitlab.com/evatix-go/core@v1.3.55/cmd/main/nullTesting02.go (about)

     1  package main
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  
     7  	"gitlab.com/evatix-go/core/isany"
     8  )
     9  
    10  func nullTesting02() {
    11  	var ex error
    12  	var inx, inx2 *int
    13  	items := []interface{}{
    14  		nil,
    15  		nil,
    16  		errors.New("x"),
    17  		ex,
    18  		inx,
    19  		inx2,
    20  	}
    21  
    22  	fmt.Println("DefinedBoth(nil, errors.New(\"x\")) = ", isany.DefinedBoth(nil, errors.New("x")))
    23  	fmt.Println("NullBoth(nil,errors.New(\"x\")) = ", isany.NullBoth(nil, errors.New("x")))
    24  	fmt.Println("NullBoth(nil,nil) = ", isany.NullBoth(nil, nil))
    25  	fmt.Println("DefinedBoth(nil,nil) = ", isany.DefinedBoth(nil, nil))
    26  	fmt.Println("NullBoth(inx,inx2) = ", isany.NullBoth(inx, inx2))
    27  
    28  	for i, item := range items {
    29  		fmt.Println(i, "- {(DefinedBoth, NullBoth, ==nil, %T} == ",
    30  			isany.DefinedBoth(item, item),
    31  			isany.NullBoth(item, item),
    32  			item == nil,
    33  			fmt.Sprintf("%T", item))
    34  	}
    35  
    36  	fmt.Println("----------------------")
    37  
    38  	for i, item := range items {
    39  		NullPrinter(i, item)
    40  	}
    41  }