{"action":"created","issue":{"url":"https://api.github.com/repos/customerio/go-customerio/issues/1","labels_url":"https://api.github.com/repos/customerio/go-customerio/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/customerio/go-customerio/issues/1/comments","events_url":"https://api.github.com/repos/customerio/go-customerio/issues/1/events","html_url":"https://github.com/customerio/go-customerio/issues/1","id":121506385,"number":1,"title":"HTTP call made by library might fail & panic","user":{"login":"exklamationmark","id":1295869,"avatar_url":"https://avatars.githubusercontent.com/u/1295869?v=3","gravatar_id":"","url":"https://api.github.com/users/exklamationmark","html_url":"https://github.com/exklamationmark","followers_url":"https://api.github.com/users/exklamationmark/followers","following_url":"https://api.github.com/users/exklamationmark/following{/other_user}","gists_url":"https://api.github.com/users/exklamationmark/gists{/gist_id}","starred_url":"https://api.github.com/users/exklamationmark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exklamationmark/subscriptions","organizations_url":"https://api.github.com/users/exklamationmark/orgs","repos_url":"https://api.github.com/users/exklamationmark/repos","events_url":"https://api.github.com/users/exklamationmark/events{/privacy}","received_events_url":"https://api.github.com/users/exklamationmark/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-10T15:06:24Z","updated_at":"2015-12-10T16:50:59Z","closed_at":"2015-12-10T16:50:59Z","body":"Hi, I was using the library to do some job, and was sending out events to customer.io.\r\nMy program panicked & crashed, and from the stack trace the problem seems to happen here:\r\n\r\nhttps://github.com/customerio/go-customerio/blob/master/customerio.go#L120\r\n\r\nThe call `http.DefaultClient.Do(req)` might actually fail, thus produce a nil resp and an error.\r\nIn this case, the call `resp.StatusCode` will fail (nil pointer), and this panic doesn't seem to be handled.\r\n\r\nI would suggest the following fix\r\n```go\r\n\tresp, err := http.DefaultClient.Do(req)\r\n\tif err != nil {\r\n\t\treturn 0, nil, err // and let the caller handle the error\r\n\t}\r\n\t// else case, but since we returned earlier, we don't need a block\r\n\tdefer resp.Body.Close()\r\n\tstatus = resp.StatusCode\r\n\tif resp.ContentLength >= 0 {\r\n\t\tresponseBody = make([]byte, resp.ContentLength)\r\n\t\tresp.Body.Read(responseBody)\r\n\t}\r\n```"},"comment":{"url":"https://api.github.com/repos/customerio/go-customerio/issues/comments/163685017","html_url":"https://github.com/customerio/go-customerio/issues/1#issuecomment-163685017","issue_url":"https://api.github.com/repos/customerio/go-customerio/issues/1","id":163685017,"user":{"login":"idawes","id":3660200,"avatar_url":"https://avatars.githubusercontent.com/u/3660200?v=3","gravatar_id":"","url":"https://api.github.com/users/idawes","html_url":"https://github.com/idawes","followers_url":"https://api.github.com/users/idawes/followers","following_url":"https://api.github.com/users/idawes/following{/other_user}","gists_url":"https://api.github.com/users/idawes/gists{/gist_id}","starred_url":"https://api.github.com/users/idawes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idawes/subscriptions","organizations_url":"https://api.github.com/users/idawes/orgs","repos_url":"https://api.github.com/users/idawes/repos","events_url":"https://api.github.com/users/idawes/events{/privacy}","received_events_url":"https://api.github.com/users/idawes/received_events","type":"User","site_admin":false},"created_at":"2015-12-10T16:50:59Z","updated_at":"2015-12-10T16:50:59Z","body":"Thanks for raising this. Fixed in https://github.com/customerio/go-customerio/commit/5c580c54b3d1027f45aefa0acff13b4ddc466d1c"}}