Skip to content

ankitsny/go-sructs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Structs and maps demo

To Run go run main.go maps-eg.go

Declaration of a struct

    type person struct{
            f_name string
            l_prop2 int
            ...
            propn int
        }

Methods to initialize a struct

  1. user1 := person{"Vir", "li", ..., propVal}}

  2. Method #2

    user2 := person{
    	firstName: "John",
    	lastName:  "Doe",
    }
  3. Method #3

    var user3 person
    // fmt.Printf("%+v", user3) // display props name
    user3.firstName = "FirstNAME"
    user3.lastName = "LastNAME"
    user3.contact.email = "ankso@ankso.com" // if it has nested strct
    user3.contact.zipCode = 12322

Releases

No releases published

Packages

No packages published

Languages