utils

package
v0.0.0-...-b0a7dda Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsInt

func AbsInt(x int) int

AbsInt returns the absolute value of an integer.

x: the input integer int: the absolute value of the input integer

func FormatDuration

func FormatDuration(seconds float64) string

FormatDuration formats the given duration in seconds into a string in the format "hh:mm:ss".

seconds float64 - the duration in seconds to be formatted string - the formatted duration string

func GetRandomImagePathFromPath

func GetRandomImagePathFromPath(folderPath string) (string, error)

GetRandomImagePathFromPath returns a random image path from the given folder path.

It takes a folderPath string as a parameter and returns a string and an error.

func InferProtocolByPort

func InferProtocolByPort(hostname string, port int) string

InferProtocolByPort is a function that infers the protocol based on the hostname and port.

It takes a hostname of type string and a port of type int as parameters, and returns a string.

func ReadFileToBase64

func ReadFileToBase64(filePath string) (string, error)

ReadFileToBase64 reads the content of the file at the given filePath and returns it as a base64 encoded string.

Parameter: filePath string - the path to the file to be read. Return: string - the base64 encoded content of the file. error - an error if any operation fails.

func SanitizeString

func SanitizeString(input string) string

SanitizeString sanitizes the input string by removing non-printable unicode characters.

It takes a string input and returns a sanitized string.

func TrimString

func TrimString(input string, limit int) string

TrimString trims the input string to the specified limit.

It takes a string input and an integer limit as parameters and returns a string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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