when using golang gin framework, the context.Request.Body would be nil if someone already read it in some place, such as
data, _ := ioutil.ReadAll(c.Request.Body)
so in my deal, I put the data into the body again after i read it, such as
data, _ := ioutil.ReadAll(c.Request.Body)
c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(data))
however, when more than one goroutines read and put the body concurrency, the body would be dirty sometimes, for my instance, the json body would be truncated and my code finally failed to decode the json string
I will be approciate if someone could help me explain the reason, since I am not so good in the operation systems
question from:
https://stackoverflow.com/questions/65840165/why-the-context-request-body-would-be-dirty-when-many-goroutine-read-and-write-t 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…