util

package
v0.0.0-...-8b1be2f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitWithMessages

func ExitWithMessages(msg ...interface{})

func GetBool

func GetBool(arg docopt.Opts, key string) bool

func GetInt64

func GetInt64(arg docopt.Opts, key string) int64

func GetSliceString

func GetSliceString(arg docopt.Opts, key string) []string

func GetString

func GetString(arg docopt.Opts, key string) string

func NewListener

func NewListener(addr string, readTimeout, writeTimeout time.Duration) (net.Listener, error)

func NewUnixListener

func NewUnixListener(path string, readTimeout, writeTimeout time.Duration) (net.Listener, error)

Binds to a UNIX socket. If the file already exists, try to remove it before binding again. This logic is borrowed from Gunicorn (see https://github.com/benoitc/gunicorn/blob/a8963ef1a5a76f3df75ce477b55fe0297e3b617d/gunicorn/sock.py#L106)

Types

type Conn

type Conn struct {
	net.Conn
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	// contains filtered or unexported fields
}

Conn wraps a net.Conn, and sets a deadline for every read and write operation.

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

type Listener

type Listener struct {
	net.Listener
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

Listener wraps a net.Listener, and gives a place to store the timeout parameters. On Accept, it will wrap the net.Conn with our own Conn for us. Original implementation taken from https://gist.github.com/jbardin/9663312 Thanks! <3

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL