Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import "fmt"
- // Example of new variable by explicit and implicit type
- var a int
- b := "This variable will be string"
- // New data type as struct
- type Person struct {
- Name string
- Age int
- IsMan bool
- }
- // Function without parametrs, returning string which
- // belongs to Person struct
- func (p *Person) ReturnAsSentece() string {
- return fmt.Sprintf("Person %v is %d years old", p.Name, p.Age)
- }
- // Create new variable as pointer to struct Person
- person := &Person{"Pavel", 23, true}
- fmt.Println(person.ReturnAsSentence())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement