index work

This commit is contained in:
Mark McGranaghan
2012-09-23 14:54:59 -07:00
parent 1c63eb272c
commit 434392e67c
100 changed files with 5 additions and 32 deletions

24
026-errors/errors.go Normal file
View File

@@ -0,0 +1,24 @@
// ## Errors
package main
import ("fmt"; "errors")
func myFun(arg int) (int, error) {
if arg == 42 {
return -1, errors.New("Can't work with 42")
}
return arg + 3, nil
}
func main() {
r, _ := myFun(7)
fmt.Println(r)
_, e := myFun(42)
fmt.Println(e)
}
// todo: custom errors
// todo: data conveying errors