utils

package
v0.0.0-...-7857e79 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsDiffInt

func AbsDiffInt(x, y int) int

absDiffInt calculates the absolute difference between two integers.

x, y are the integers to find the absolute difference between. int is the return type, representing the absolute difference.

func AbsDiffUint

func AbsDiffUint(x, y uint) uint

absDiffUint calculates the absolute difference between two unsigned integers.

x, y uint uint

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 GetWeightedRandomImagePath

func GetWeightedRandomImagePath(folderPath string) (string, error)

GetWeightedRandomImagePath returns a random image path with reduced chances for recently shown images.

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 IsYouTubeURL

func IsYouTubeURL(url string) bool

func Min

func Min(a, b int) int

min returns the minimum of two integers.

Parameters:

a int - the first integer
b int - the second integer

Return type:

int - the minimum of the two integers

func ParseFloat64

func ParseFloat64(s string) (float64, error)

parseFloat64 parses the input string as a 64-bit floating point number.

It takes a string as input and returns a float64 and an error.

func ParseInt

func ParseInt(s string) (int, error)

parseInt parses the input string to an integer.

It takes a string as input and returns an integer and an error.

func ParseInt64

func ParseInt64(s string) (int64, error)

parseInt64 parses the input string into a 64-bit signed integer.

It takes a string as a parameter and returns a 64-bit signed integer and an error.

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