Standard library / net

net.Conn

Bidirectional byte-stream interface with deadlines and close. Expected stdout: 'pipe\n'.

Formal Syntax & Structure

go syntaxgo
type Conn interface {  Read(b []byte) (n int, err error)
  Write(b []byte) (n int, err error)
  Close() error
  LocalAddr() Addr
  RemoteAddr() Addr
  SetDeadline(t time.Time) error
  SetReadDeadline(t time.Time) error
  SetWriteDeadline(t time.Time) error}

Working Example

Example Snippetgo
package main
import (  "fmt"  "net")
func main() {  a, b := net.Pipe()  defer a.Close()  defer b.Close()  var v net.Conn = a  fmt.Println(v.LocalAddr().Network())}
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