嗨 friend 们我想在写入器中写入数据并使用读取器将其传递到库以便它可以读取 现在我遇到的问题是png。编码不再继续并卡在那里
r, w := io.Pipe()
err := png.Encode(w, img)
如果可能的话请告诉我解决方案。当然,我不在乎这个问题是否得到解决,如果您知道数据在写入器中写入并在读取器中读取的情况的另一种解决方案,请提出建议,还有辅助解决方案,但我使用两个库,一个是只需要一位作家和一位读者。
最佳答案
w
被阻塞,等待读取器读取写入管道的数据,从而阻塞 Encode
从r
读取将解锁Encode
写入器..
each Write to the PipeWriter blocks until it has satisfied one or more Reads from the PipeReader that fully consume the written data
关于go - io.Pipe使用困难,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73619455/