英文:
How to append text to a file in golang?
问题
我发现os.Open()返回一个O_RDONLY文件,os.Create()返回一个O_RDWR文件,但找不到一个方法返回一个APPEND文件指针。
有什么帮助吗?
英文:
I find os.Open() return a O_RDONLY file and os.Create() return a O_RDWR but can't find a method return a APPEND file pointer.
Any help ?
答案1
得分: 55
The OpenFile takes a flags argument that you can use:
os.OpenFile("foo.txt", os.O_RDWR|os.O_APPEND, 0660);
Used with O_CREATE , OpenFile can also serve the same purpose as os.Create()
英文:
The OpenFile takes a flags argument that you can use:
os.OpenFile("foo.txt", os.O_RDWR|os.O_APPEND, 0660);
Used with O_CREATE , OpenFile can also serve the same purpose as os.Create()
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论