Created
February 5, 2014 20:11
-
-
Save squarism/8832059 to your computer and use it in GitHub Desktop.
Go Spiking
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
// imma go newb. | |
package main | |
import "fmt" | |
type User struct { | |
email string | |
enabled bool | |
} | |
func (user *User) EnableAccount() { | |
user.enabled = true | |
} | |
func (user *User) DisableAccount() { | |
user.enabled = false | |
} | |
// pointers and struct objects! weee! | |
func main() { | |
sandy := new(User) | |
sandy.email = "sandy@gmail.com" | |
fmt.Println(*sandy) | |
sandy.EnableAccount() | |
fmt.Println(*sandy) | |
sandy.DisableAccount() | |
fmt.Println(*sandy) | |
} | |
/* | |
{sandy@gmail.com false} | |
{sandy@gmail.com true} | |
{sandy@gmail.com false} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment