github.com/giovannyortegon/go@v0.0.0-20220115155912-8890063f5bdd/Profesional/Structures/RelationalStructure.go (about)

     1  package main
     2  
     3  import "fmt"
     4  
     5  type User struct {
     6  	nombre string
     7  	email string
     8  	activo bool
     9  }
    10  
    11  type Student struct {
    12  	user User
    13  	codigo string
    14  }
    15  
    16  func main() {
    17  	alex := User {
    18  		nombre: "Alex",
    19  		email: "alex@hotmail.com",
    20  		activo: true,
    21  	}
    22  
    23  	roel := User {
    24  		nombre: "Roel",
    25  		email: "roel@hotmail.com",
    26  		activo: true,
    27  	}
    28  
    29  	alexStudent := Student{
    30  		user: alex,
    31  		codigo: "RS23132",
    32  	}
    33  
    34  	fmt.Println(alex)
    35  	fmt.Println(roel)
    36  	fmt.Println(alexStudent)
    37  	fmt.Println(alexStudent.user.nombre)
    38  
    39  }