如何在StreamWriter中使用Close()方法

huangapple go评论88阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2013年5月9日 13:45:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/16455200.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定