Documentation
¶
Index ¶
- Variables
- func AppendPort(addr string, defaultPort int) string
- func Fatalf(format string, v ...interface{})
- func FatalfIf(condition bool, format string, v ...interface{})
- func GetEnv(key string, defaultVal string) string
- func GetEnvBool(key string, defaultVal bool) bool
- func If[T any](condition bool, a, b T) T
- func Postfix(addr, postfix string) string
- func Prefix(prefix, addr string) string
- func PrintQRCode(baseURL, code string)
- func Printf(format string, a ...any)
- func RandFull(buf []byte)
- func RandIntn(n int) int
- func RandPass(n int) []byte
- func TimeoutCloser(c io.Closer, timeout time.Duration) io.Closer
- func TimeoutReadWriter(rw io.ReadWriter, timeout time.Duration) io.ReadWriter
- func TimeoutReader(r io.Reader, timeout time.Duration) io.Reader
- func TimeoutWriter(w io.Writer, timeout time.Duration) io.Writer
- type CliProgressBar
- type Duration
- type NoopProgressBar
- type ProgressBar
- type Reader
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ErrTimeout = errors.New("timeout occurred")
ErrTimeout is returned by TimeoutCloser, TimeoutReader, and TimeoutWriter when the underlying Closer/Reader/Writer does not return within the specified timeout
Functions ¶
func AppendPort ¶
AppendPort appends a port to the address e.g. AppendPort(`124.223.81.61:3478?transport=udp`, 3478) => 124.223.81.61:3478?transport=udp e.g. AppendPort(`124.223.81.61?transport=udp`, 3478) => 124.223.81.61:3478?transport=udp e.g. AppendPort(`124.223.81.61`, 3478) => 124.223.81.61:3478
func GetEnvBool ¶
func PrintQRCode ¶
func PrintQRCode(baseURL, code string)
func TimeoutCloser ¶
TimeoutCloser returns an io.Closer that wraps the passed-in io.Closer. If the underlying Closer fails to close within the allotted timeout ErrTimeout is returned.
func TimeoutReadWriter ¶
func TimeoutReadWriter(rw io.ReadWriter, timeout time.Duration) io.ReadWriter
TimeoutReadWriter returns an io.ReadWriter that wraps the passed-in io.ReadWriter. If the underlying ReadWriter fails to read/write within the allotted timeout ErrTimeout is returned.
func TimeoutReader ¶
TimeoutReader returns an io.Reader that wraps the passed-in io.Reader. If the underlying Reader fails to read within the allotted timeout ErrTimeout is returned.
Types ¶
type CliProgressBar ¶
type CliProgressBar struct {
// contains filtered or unexported fields
}
func (*CliProgressBar) Add ¶
func (c *CliProgressBar) Add(n uint64)
func (*CliProgressBar) Finish ¶
func (c *CliProgressBar) Finish()
func (*CliProgressBar) Start ¶
func (c *CliProgressBar) Start(filename string, n uint64)
type NoopProgressBar ¶
type NoopProgressBar struct{}
func (*NoopProgressBar) Add ¶
func (n *NoopProgressBar) Add(uint64)
func (*NoopProgressBar) Finish ¶
func (n *NoopProgressBar) Finish()
func (*NoopProgressBar) Start ¶
func (n *NoopProgressBar) Start(string, uint64)
type ProgressBar ¶
func CreateProgressBar ¶
func CreateProgressBar(pb ProgressBar, progress bool) ProgressBar
type Reader ¶
type Reader struct { io.Reader ProgressBar }
Reader it's a wrapper for given reader, but with progress handle
func NewProxyReader ¶
func NewProxyReader(r io.Reader, pb ProgressBar) *Reader
NewProxyReader creates a wrapper for given reader, but with progress handle Takes io.Reader or io.ReadCloser Also, it automatically switches progress bar to handle units as bytes
type Writer ¶
type Writer struct { io.Writer ProgressBar }
Writer it's a wrapper for given writer, but with progress handle
func NewProxyWriter ¶
func NewProxyWriter(r io.Writer, pb ProgressBar) *Writer
NewProxyWriter creates a wrapper for given writer, but with progress handle Takes io.Writer or io.WriteCloser Also, it automatically switches progress bar to handle units as bytes