Created
December 12, 2019 06:43
-
-
Save viveksinghggits/6ca0aface93ebc90503e13dc77f3255c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"errors" | |
_ "time" | |
) | |
type Person struct{ | |
age int | |
firstName, lastName string | |
} | |
func main(){ | |
fmt.Println("Hello There!!!") | |
person:= &Person{ | |
age: 0, | |
firstName: "Vivek", | |
lastName:"Singh", | |
} | |
_, minor := person.checkMinor() | |
fmt.Println("Person is Minor", minor) | |
fmt.Println(person) | |
person.changePersonsAge(234) | |
fmt.Println(person) | |
} | |
func (p *Person) changePersonsAge(newAge int) error { | |
p.age = newAge | |
return nil | |
} | |
func (p *Person) checkMinor() (error, bool) { | |
if true{ | |
return errors.New("Person's age is not provided"), false | |
} | |
if p.age <18{ | |
return nil, true | |
} else{ | |
return nil, false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment