utils

package
v0.92.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Overview

Package utils provides shared utility functions.

Index

Constants

View Source
const EmbedServerPort = "15656"

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(b []byte) string

BytesToString converts byte slice to string without allocation.

func CheckSingleton added in v0.13.1

func CheckSingleton() error

func DecodeJSON added in v0.35.2

func DecodeJSON(r io.Reader, v any) error

func DefaultRestyClient added in v0.35.2

func DefaultRestyClient() *resty.Client

func DownloadFile added in v0.32.1

func DownloadFile(url, filename string) error

func EmbedServer added in v0.13.1

func EmbedServer() error

func EncodeJSON added in v0.35.2

func EncodeJSON(w io.Writer, v any) error

func EncodeJSONEscapeHTML added in v0.35.2

func EncodeJSONEscapeHTML(w io.Writer, v any, esc bool) error

func EncodeJSONEscapeHTMLIndent added in v0.35.2

func EncodeJSONEscapeHTMLIndent(w io.Writer, v any, esc bool, indent string) error

func FileExist

func FileExist(name string) bool

func GetFunctionName

func GetFunctionName(i any) string

func GetRemoteAddr

func GetRemoteAddr(req *http.Request) string

GetRemoteAddr Obtain IP address of the client.

func HTTPTransport added in v0.92.0

func HTTPTransport() *http.Transport

HTTPTransport returns the shared HTTP transport with connection pool tuning. Provider implementations that create raw http.Client instances should use this instead of http.DefaultTransport to ensure consistent pool behavior across all outgoing provider calls.

func HasHan

func HasHan(txt string) bool

func HostInfo added in v0.35.1

func HostInfo() (string, string, error)

func IsRoutableIP

func IsRoutableIP(ipStr string) bool

func IsUnixAddr

func IsUnixAddr(addr string) bool

IsUnixAddr Check if specified address is a unix socket like "unix:/run/flowbot.sock".

func IsUrl

func IsUrl(text string) bool

func NetListener

func NetListener(addr string) (net.Listener, error)

NetListener creates net.Listener for tcp and unix domains: if addr is in the form "unix:/run/flowbot.sock" it's a unix socket, otherwise TCP host:port.

func NewUUID

func NewUUID() string

func ParseFunctionName

func ParseFunctionName(name string) (string, string)

func PortAvailable added in v0.13.1

func PortAvailable(port string) bool

func RandomString added in v0.32.1

func RandomString(n int) (string, error)

func RestyClientWithTrace added in v0.92.0

func RestyClientWithTrace() *resty.Client

RestyClientWithTrace returns a resty client configured with OTel HTTP tracing. The underlying http.Transport is wrapped with otelhttp.NewTransport which automatically propagates W3C TraceContext headers and creates client spans for outgoing requests.

Providers should use SetContext(ctx) on individual requests to ensure the span context is propagated from the caller's context.

func SHA256 added in v0.92.0

func SHA256(txt string) string

func SameStringSlice

func SameStringSlice(x, y []string) bool

func SignalHandler added in v0.18.1

func SignalHandler() <-chan bool

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes converts string to byte slice without allocation.

func ToAbsolutePath

func ToAbsolutePath(base, path string) string

ToAbsolutePath Convert relative filepath to absolute.

func ValidImageContentType

func ValidImageContentType(ct string) bool

Types

This section is empty.

Directories

Path Synopsis
Package reexec facilitates the busybox style reexec of the docker binary that we require because of the forking limitations of using Go.
Package reexec facilitates the busybox style reexec of the docker binary that we require because of the forking limitations of using Go.
Package sets provides generic set data structures.
Package sets provides generic set data structures.
Package syncx provides synchronized concurrent-safe data structures.
Package syncx provides synchronized concurrent-safe data structures.

Jump to

Keyboard shortcuts

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