utils

package
v0.19.8 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const EnvAmHostname = "AM_HOSTNAME"

EnvAmHostname will override the hostname in all machine names.

Variables

Fmt is a printer for large numbers

Functions

func CaptureStackTrace added in v0.17.0

func CaptureStackTrace() string

func CloseSafe added in v0.10.1

func CloseSafe[T any](ch chan T)

TODO remove if that speeds things up

func DialWebSocket added in v0.19.7

func DialWebSocket(
	ctx context.Context, urlStr string, protocols []string, timeout time.Duration,
) (net.Conn, error)

DialWebSocket dials a WebSocket endpoint and returns a net.Conn carrying binary messages as a byte stream. Useful for tunneling stream protocols.

func GetGlobalUnicastIp added in v0.19.6

func GetGlobalUnicastIp() (string, error)

func GetVersion

func GetVersion() string

func Hostname

func Hostname() string

func J

func J(states []string) string

J joins state names into a single string

func Jw

func Jw(states []string, sep string) string

Jw joins state names into a single string with a separator.

func NewServerWSConn added in v0.19.7

func NewServerWSConn(
	conn net.Conn, rw *bufio.ReadWriter,
) (net.Conn, error)

NewServerWSConn wraps an already upgraded server-side WebSocket into a net.Conn.

func P added in v0.10.2

func P(txt string, args ...any)

func PadString added in v0.17.0

func PadString(str string, length int, pad string) string

func RandId added in v0.10.1

func RandId(strLen int) string

RandId generates a random ID of the given length (defaults to 8).

func SlicesEvery added in v0.10.1

func SlicesEvery[S1 ~[]E, S2 ~[]E, E comparable](col1 S1, col2 S2) bool

SlicesEvery returns true if all elements of coll2 are in coll1.

func SlicesNone added in v0.10.1

func SlicesNone[S1 ~[]E, S2 ~[]E, E comparable](col1 S1, col2 S2) bool

SlicesNone returns true if none of the elements of coll2 are in coll1.

func SlicesUniq added in v0.10.1

func SlicesUniq[S ~[]E, E comparable](coll S) S

func SlicesWithout added in v0.10.1

func SlicesWithout[S ~[]E, E comparable](coll S, el E) S

func Sp added in v0.10.2

func Sp(txt string, args ...any) string

func TruncateStr added in v0.17.0

func TruncateStr(s string, maxLength int) string

TruncateStr with shorten the string and leave a tripedot suffix.

Types

This section is empty.

Jump to

Keyboard shortcuts

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