Skip to content

Instantly share code, notes, and snippets.

@squarism
Created February 5, 2014 20:11
Show Gist options
  • Save squarism/8832059 to your computer and use it in GitHub Desktop.
Save squarism/8832059 to your computer and use it in GitHub Desktop.
Go Spiking
// 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