Standard library / io
io.PipeWriter.Close()
Closes the write end so the reader receives EOF after all delivered bytes. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (w *PipeWriter) Close() errorReturn Value
error
Closes the write end so the reader receives EOF after all delivered bytes.
Working Example
Example Snippetgo
package main
import ( "fmt" "io")
func main() { r, w := io.Pipe() defer r.Close() w.Close() _, e := r.Read(make([]byte, 1)) fmt.Println(e == io.EOF)}