github.com/giovannyortegon/go@v0.0.0-20220115155912-8890063f5bdd/src/BlackHatGo/Chap01/structs/structs.go (about)

     1  package main
     2  
     3  import "fmt"
     4  
     5  type aStructure struct {
     6  	person string
     7  	height int
     8  	weight int
     9  }
    10  
    11  func main() {
    12  
    13  	mySlice := make([]aStructure, 0)
    14  
    15  	mySlice = append(mySlice, aStructure{"Mihalis", 180, 90})
    16  	mySlice = append(mySlice, aStructure{"Bill", 134, 45})
    17  	mySlice = append(mySlice, aStructure{"Marietta", 155, 45})
    18  
    19  	fmt.Println("0:", mySlice)
    20  
    21  	integers := make([]int, 2)
    22  
    23  	integers = nil
    24  	integers = append(integers, 10)
    25  	integers = append(integers, 20)
    26  	fmt.Println(integers)
    27  
    28  	for _, idx := range integers {
    29  		fmt.Println(idx)
    30  		if idx == nil {
    31  			fmt.Println("nil found")
    32  		}
    33  	}
    34  }