AlienVault-OTX / OTX-Go-SDK

A working client implementation for AlienVault OTX API written in Golang!
https://otx.alienvault.com
Apache License 2.0
55 stars 23 forks source link

handle all errors gracefully #2

Open bsmartt13 opened 8 years ago

bsmartt13 commented 8 years ago

don't die like this:

/usr/local/Cellar/go/1.4.2/libexec/bin/go build -o "/private/var/folders/6_/0cj9yrxd0l76c60yh6mws2480000gn/T/otxapi (main)4go" -gcflags "-N -l" /Users/bsmartt/Dev/golang/go-otx-api-client/examples/main.go
"/Users/bsmartt/Library/Application Support/IntelliJIdea15/Go/lib/dlv/mac/dlv" --listen=localhost:59179 --headless=true exec "/private/var/folders/6_/0cj9yrxd0l76c60yh6mws2480000gn/T/otxapi (main)4go" --
/api/v1/user/ response status: 403
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x2c7d]

goroutine 1 [running]:
main.main()
    /Users/bsmartt/Dev/golang/go-otx-api-client/examples/main.go:24 +0xc7d

goroutine 9 [runnable]:
net/http.(*persistConn).readLoop(0xc208074000otxapi.UserDetail{}

)
    /usr/local/Cellar/go/1.4.2/libexec/src/net/http/transport.go:928 +0x9ce
created by net/http.(*Transport).dialConn
    /usr/local/Cellar/go/1.4.2/libexec/src/net/http/transport.go:660 +0xc9f

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /usr/local/Cellar/go/1.4.2/libexec/src/runtime/asm_amd64.s:2232 +0x1

goroutine 10 [select]:
net/http.(*persistConn).writeLoop(0xc208074000)
    /usr/local/Cellar/go/1.4.2/libexec/src/net/http/transport.go:945 +0x41d
created by net/http.(*Transport).dialConn
    /usr/local/Cellar/go/1.4.2/libexec/src/net/http/transport.go:661 +0xcbc