Skip to content

Instantly share code, notes, and snippets.

@wwalker
Last active December 1, 2015 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wwalker/ba00b21d33fee7b46da5 to your computer and use it in GitHub Desktop.
Save wwalker/ba00b21d33fee7b46da5 to your computer and use it in GitHub Desktop.
uh.... why panic?
// Author wwalker
package main
import (
"os"
"gopkg.in/yaml.v2"
)
func main() {
var result interface{}
var err error
var data []byte = []byte("---\ndata_resources: \"asdf\"\n")
if err = yaml.Unmarshal(data, result); err != nil {
println(err)
os.Exit(1)
}
}
wwalker@hatter:~/golang_workspace/src/devops/mcm$ go build
wwalker@hatter:~/golang_workspace/src/devops/mcm$ ./mcm
panic: reflect: call of reflect.Value.Type on zero Value [recovered]
panic: reflect: call of reflect.Value.Type on zero Value
goroutine 1 [running]:
gopkg.in/yaml%2ev2.handleErr(0xc8200abef0)
/home/wwalker/golang_workspace/src/gopkg.in/yaml.v2/yaml.go:153 +0xdf
reflect.Value.Type(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/reflect/value.go:1664 +0x7b
gopkg.in/yaml%2ev2.(*decoder).terror(0xc820014780, 0xc8200222a0, 0x5a7cf0, 0x15, 0x0, 0x0, 0x0)
/home/wwalker/golang_workspace/src/gopkg.in/yaml.v2/decode.go:221 +0x262
gopkg.in/yaml%2ev2.(*decoder).mapping(0xc820014780, 0xc8200222a0, 0x0, 0x0, 0x0, 0x0)
/home/wwalker/golang_workspace/src/gopkg.in/yaml.v2/decode.go:532 +0xc3b
gopkg.in/yaml%2ev2.(*decoder).unmarshal(0xc820014780, 0xc8200222a0, 0x0, 0x0, 0x0, 0xc820038028)
/home/wwalker/golang_workspace/src/gopkg.in/yaml.v2/decode.go:292 +0x135
gopkg.in/yaml%2ev2.(*decoder).document(0xc820014780, 0xc820022240, 0x0, 0x0, 0x0, 0xc8200abe20)
/home/wwalker/golang_workspace/src/gopkg.in/yaml.v2/decode.go:304 +0xa3
gopkg.in/yaml%2ev2.(*decoder).unmarshal(0xc820014780, 0xc820022240, 0x0, 0x0, 0x0, 0x1b)
/home/wwalker/golang_workspace/src/gopkg.in/yaml.v2/decode.go:280 +0x5f
gopkg.in/yaml%2ev2.Unmarshal(0xc8200125e0, 0x1b, 0x20, 0x0, 0x0, 0x0, 0x0)
/home/wwalker/golang_workspace/src/gopkg.in/yaml.v2/yaml.go:90 +0x2aa
main.main()
/home/wwalker/golang_workspace/src/devops/mcm/main.go:16 +0x96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment