package main import ( "fmt" "os" "os/signal" "syscall" ) func main() { signal.Ignore(syscall.SIGPIPE) for { _, err := fmt.Println("Wow!") if err != nil { if e, ok := err.(*os.PathError); ok && e.Err == syscall.EPIPE { break } else { panic(err) } } } }