Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close bug #8

Open
BoxuanXu opened this issue May 16, 2020 · 0 comments
Open

Close bug #8

BoxuanXu opened this issue May 16, 2020 · 0 comments

Comments

@BoxuanXu
Copy link

hello,here is a bug,if err is not nil, then defer res.Body.Close(),will panic.
`func (request *Request) Execute() (response string, ret error) {
if request.ApiKey == "" || request.Method == "" {
return "", Error("Need both API key and method")
}

s := request.URL()

res, err := http.Get(s)
defer res.Body.Close()
if err != nil {
	return "", err
}

body, _ := ioutil.ReadAll(res.Body)
return string(body), nil

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant