golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.85k stars 17.65k forks source link

gomobile http request crashes app #44590

Closed bramvbilsen closed 3 years ago

bramvbilsen commented 3 years ago

What version of Go are you using (go version)?

go version go1.15.8 windows/amd64

What did you do?

I am trying to send some data to a webserver before the app starts. I am using the basic example app template included in gomobile. I added the following code at the start of main:

client := &http.Client{}
req, _ := http.NewRequest("GET", "X.X.X.X:8000/log", strings.NewReader("TEST"))
client.Do(req)

I inserted it at the start of main:

func main() {
    client := &http.Client{}
    req, _ := http.NewRequest("GET", "X.X.X.X:8000/log", strings.NewReader("TEST"))
    client.Do(req)
    app.Main(func(a app.App) {
                ...
        }
        ....
}

What did you expect to see?

A log on my webserver and the app not crashing.

What did you see instead?

No log on my webserver and the app crashes.

seankhliao commented 3 years ago

don't ignore errors

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions