• Golang - Как использовать вложенные структуры?

    @vasyash
    Чуток переписал код. Вложенные структуры объявляются по другому.
    package main
    
    import "fmt"
    
    type UserData struct {
    	LastActivity        int64
    	MoneyBalance        int64
    	BonusBalace         uint64
    	NalogNumber         uint64
    	PassportSerial      uint64
    	PassportNumber      uint64
    	PassportDepartament string
    	PassportDate        uint64
    	BussinesStatus      bool
    }
    type UserExp struct {
    	UniverType  string
    	UniverName  string
    	UniverDate  int16
    	SpecialDoc  string
    	CoursesOrg  string
    	CoursesName string
    	CoursesDate uint64
    }
    type User struct {
    	UserId      uint64
    	FirstName   string
    	Name        string
    	LastName    string
    	BirthDay    uint64
    	PhoneNumber uint64
    	Mail        string
    	ActivePass  bool
    	UserBase    UserData
    	Experience  UserExp
    }
    
    func main() {
    	var ViewPage = User{
    		UserId:      10,
    		FirstName:   "Yakovsky",
    		Name:        "Bob",
    		LastName:    "Jonson",
    		BirthDay:    123,
    		PhoneNumber: 9999990000,
    		Mail:        "bob.Jonson@mail.net",
    		ActivePass:  true,
    		UserBase: UserData{
    			LastActivity:        123,
    			MoneyBalance:        1000,
    			BonusBalace:         10,
    			NalogNumber:         123456789,
    			PassportSerial:      1928,
    			PassportNumber:      321456,
    			PassportDepartament: "MVD from Moscow",
    			PassportDate:        123,
    			BussinesStatus:      false,
    		},
    		Experience: UserExp{
    			UniverType:  "University",
    			UniverName:  "TGGPU",
    			UniverDate:  2007,
    			SpecialDoc:  "manager",
    			CoursesOrg:  "MFTI",
    			CoursesName: "Programmer",
    			CoursesDate: 2013,
    		},
    	}
    	fmt.Println(ViewPage.Experience.CoursesOrg)
    }
    Ответ написан