Standard library / net/textproto

textproto.Conn.Close()

Close the underlying connection; subsequent I/O fails. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (c *Conn) Close() error

Return Value

error

Nil on success, otherwise the operation error.

Working Example

Example Snippetgo
package main
import (  "fmt"  "net"  "net/textproto"  "time")
func main() {  c, s := net.Pipe()  defer c.Close()  defer s.Close()  check(c.SetDeadline(time.Now().Add(3 * time.Second)))  check(s.SetDeadline(time.Now().Add(3 * time.Second)))  tp := textproto.NewConn(c)  defer tp.Close()  check(tp.Close())  _, e := c.Write([]byte("x"))  fmt.Println(e != nil)}
func must[T any](v T, e error) T {  if e != nil {    panic(e)  }  return v}func check(e error) {  if e != nil {    panic(e)  }}
Go Reference