英文:
How to use Close() method in StreamWriter
问题
在Go的crypto/cipher包中,类型StreamWriter有一个Close()方法。从实现来看,它似乎只是调用底层io.Writer的Close()方法。我的问题是:是否有任何情况下我应该调用这个方法,而不是直接调用底层Writer的Close()方法?
英文:
In Go crypto\cipher package, type StreamWriter has a Close() method. From the implementation, it looks like just calling the underlying io.Writer's Close() method. My question is: is there any scenario that I should call this method instead of calling the Close() method of the underlying Writer directly?
答案1
得分: 1
不,调用StreamWriter的close方法和调用底层writer的close方法是完全相同的。只是为了让StreamWriter实现io.WriteCloser接口而存在。
只有因为这个方法的存在,这个类型才能被用作io.WriteCloser。
英文:
No, calling StreamWriter's close method and calling the underlying writer's close method is exactly the same. It is only there so StreamWriter will implement the io.WriteCloser interface.
It is only because this method exists that the type can be used as an io.WriteCloser.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论