Standard library / io
io.WriteCloser
Combines Writer and Closer, useful for sinks needing explicit cleanup. Expected stdout: 'ok <nil>\n'.
Formal Syntax & Structure
go syntaxgo
type WriteCloser interface { Writer Closer}Working Example
Example Snippetgo
package main
import ( "bytes" "fmt" "io" "strings")
func main() { var b bytes.Buffer var w io.WriteCloser = struct { *bytes.Buffer io.Closer }{&b, io.NopCloser(strings.NewReader(""))} w.Write([]byte("ok")) fmt.Println(b.String(), w.Close())}