ResponseWriterState nil in goroutine

Hello everyone,

First, I’m new to go and so this might be a rookie mistake.
What I’m trying to do is the following:

  1. Receive request
  2. Start loading multiple files
  3. After the first file is loaded, return it as a HTTP response.
  4. Use HTTP2 push to push the remaining files to the client.

I tried sleeping until all files were loaded and then returning 1 as a normal reponse and pushing the other ones. This works, but as you can imagine, I don’t want to wait for all files to load.
So I tried to create a goroutine that loads the files and tries to push them to the client while the main function returns after receiving the first file.

However, when doing this, I get a segmentation violation, more specifically the “http2responseWriterState” of the “http2responseWriter” is nil. Note that the “http2responseWriter” itself is not nil.

I know this is a pretty specific problem, but does anyone have an idea what might cause this?

Edit: Even if I pause the main function and not return immediately, this segmentation violation still occurrs. So I don’t think the problem is the responseWriter closing before I try to write to it.

Is this about Caddy or are you asking a Go question? If you’re writing Go code, you should probably ask on the Go forum: https://forum.golangbridge.org and be sure to post your code, or nobody will be able to help you.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.