some basic example of how pointer works ,etc..

This commit is contained in:
jian.han 2018-01-18 16:44:13 +10:00
parent 64df91e09c
commit 967befa56b

View File

@ -1,8 +1,55 @@
package main
import "github.com/jianhan/go-patterns/concurrency/subtasks/fetchers"
import (
"errors"
"github.com/davecgh/go-spew/spew"
)
type Person struct {
Name string
}
type Dog struct {
Name string
}
type House struct {
person *Person
dog *Dog
}
func main() {
// divide_and_conquer.RunDivideAndConquer()
fetchers.RunFetchers()
// fetchers.RunFetchers()
// h := &House{}
// spew.Dump(h)
// go func() {
// defer fmt.Println("Returned")
// for {
// select {
// default:
// return
// }
// }
// fmt.Println("TEST")
// }()
// time.Sleep(time.Second)
// spew.Dump(caller())
// spew.Dump(nakedReturn())
}
func nakedReturn() (i uint32, err error) {
return 12, errors.New("Test")
}
func caller() (d *Dog, err error) {
p, err := produceErr()
spew.Dump(p)
return
}
func produceErr() (*Person, error) {
return &Person{Name: "James"}, errors.New("New Error")
}