First, I’m new to go and so this might be a rookie mistake.
What I’m trying to do is the following:
- Receive request
- Start loading multiple files
- After the first file is loaded, return it as a HTTP response.
- 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.