Created
June 22, 2018 19:31
-
-
Save gagliardetto/c720e1b01a1a1c9689ada38320ec7c5d to your computer and use it in GitHub Desktop.
Revisions
-
gagliardetto created this gist
Jun 22, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ package main import "fmt" func main() { user := User{} // Set the group: groupSetter("admin", user) fmt.Println(user) } type User struct { Name string group string } // GetGroup returns the group the user belongs to. func (user *User) GetGroup() string { return user.group } func groupSetter(name string, user UserInterface) error { return user.SetGroup(name) } // type UserInterface interface { GetGroup() string SetGroup(name string) error }