awesome-patterns/concurrency/subtasks/main.go

56 lines
812 B
Go
Raw Permalink Normal View History

2018-01-05 08:26:58 +03:00
package main
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
}
2018-01-05 08:26:58 +03:00
func main() {
2018-01-06 08:55:04 +03:00
// divide_and_conquer.RunDivideAndConquer()
// 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")
2018-01-05 08:26:58 +03:00
}