Skip to content

Instantly share code, notes, and snippets.

@nicholasf
Created July 29, 2014 09:58
Show Gist options
  • Save nicholasf/e17ee055cb4fb7b5a838 to your computer and use it in GitHub Desktop.
Save nicholasf/e17ee055cb4fb7b5a838 to your computer and use it in GitHub Desktop.
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