Skip to content

Instantly share code, notes, and snippets.

@wwalker wwalker/main.go
Last active Dec 1, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.