英文:
How to read at least N bytes in Go
问题
你如何确保在Go语言中从文件读取时至少获取n个字节?该函数似乎返回你获取的字节数,但我宁愿等待更多的字节可用。在不进行大量手动操作的情况下,是否有可能实现这一点?
英文:
How do you ensure you get at least n bytes when reading from a file in Go? The function seems to return the number of bytes you got, but I would rather just wait until more bytes are available. Is this possible without doing a bunch of manual plumbing?
答案1
得分: 3
使用io.ReadAtLeast()函数:http://golang.org/pkg/io/#ReadAtLeast
英文:
Use io.ReadAtLeast() function: http://golang.org/pkg/io/#ReadAtLeast
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论