Created
July 29, 2014 09:58
-
-
Save nicholasf/e17ee055cb4fb7b5a838 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" | |
) | |
type IMsg interface { | |
SetMsg(msg string) | |
Msg() string | |
} | |
type Msgr struct { | |
msg string | |
} | |
func NewMsg() IMsg { | |
return &Msgr{ "-" } | |
} | |
func (m *Msgr) SetMsg(msg string) { | |
m.msg = msg | |
} | |
func (m Msgr) Msg() string { | |
return m.msg | |
} | |
func changer(m string, msg IMsg) { | |
msg.SetMsg(m) | |
} | |
func main() { | |
fmt.Println("Hello, playground") | |
msg := NewMsg() | |
fmt.Println(msg.Msg()) | |
changer("ok", msg) | |
fmt.Println(msg.Msg()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment