mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-24 13:36:03 +03:00
some basic example of how pointer works ,etc..
This commit is contained in:
parent
64df91e09c
commit
967befa56b
@ -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")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user