package main import ( "log" ) var res int var err error type FuncResult func() (int, error) /* func funcWithError(f chan FuncResult) { f <- (func() (int, error) { return 123, nil }) } func main() { r := make(chan FuncResult) //... } */ func funcWithError(f chan FuncResult) { f <- (func() (int, error) { return 123, nil }) } func blah() (int, error) { log.Println("Ran blah()") return 21, nil } func main() { // r := make(chan func() (int, error)) r := make(chan FuncResult) go funcWithError(r) res, err = (<-r)() if err == nil { log.Printf("My result is %d again!", res) } else { log.Printf("The func returned an error: %s", err) } /* r <= blah if err == nil { log.Printf("My result is %d again!", res) } else { log.Printf("The func returned an error: %s", err) } */ }