2015-08-07 16:50:14 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2015-10-17 07:31:07 +00:00
|
|
|
"io/ioutil"
|
2015-08-07 16:50:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type SomeType struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
type OtherType struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *SomeType) String() string {
|
|
|
|
return "SomeTypeObject"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *OtherType) String() string {
|
|
|
|
return "OtherTypeObject"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *SomeType) SomeFunction() {
|
|
|
|
fmt.Printf("SomeFunction called\n")
|
|
|
|
}
|
|
|
|
|
|
|
|
func anotherFunction() {
|
|
|
|
fmt.Printf("anotherFunction called\n")
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
var a SomeType
|
|
|
|
var b OtherType
|
2016-05-29 19:20:09 +00:00
|
|
|
i := 10
|
|
|
|
fmt.Printf("%s %s %v\n", a.String(), b.String(), i)
|
2015-08-07 16:50:14 +00:00
|
|
|
a.SomeFunction()
|
|
|
|
anotherFunction()
|
2015-10-17 07:31:07 +00:00
|
|
|
ioutil.ReadFile("nonexistent.file.txt")
|
2015-08-07 16:50:14 +00:00
|
|
|
}
|
2017-07-26 18:52:51 +00:00
|
|
|
|
|
|
|
var amap map[string]func()
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
amap = map[string]func(){
|
|
|
|
"k": func() {
|
|
|
|
fmt.Printf("hello world")
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|