utils

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateLongAndShortNames

func GenerateLongAndShortNames(longName, shortName string) (string, string)

GenerateLongAndShortNames generates the long and short names for an argument.

Parameters:

  • longName (string): The long name of the argument.
  • shortName (string): The short name of the argument.

Returns:

  • string: The long name of the argument.
  • string: The short name of the argument.

func ListOfStrings

func ListOfStrings(l []string) string

ListOfStrings converts a slice of strings into a formatted string representation. Each element of the slice is enclosed in double quotes and separated by commas. The entire output is enclosed in square brackets, mimicking a JSON-style array.

Parameters:

l ([]string): The slice of strings to be formatted.

Returns:

string: A formatted string representation of the slice, with each element quoted and separated by commas.
        Example: ["item1", "item2", "item3"]

func StringToInt

func StringToInt(value string) (int, error)

StringToInt converts a string representation of an integer in various formats (decimal, hexadecimal, octal, or binary) to an integer. The function recognizes the following prefixes: - "0x" or "0X" for hexadecimal - "0o" or "0O" for octal - "0b" or "0B" for binary If no prefix is provided, the string is treated as a decimal.

Parameters: - value: The string to convert to an integer.

Returns: - The converted integer value. - An error if the conversion fails.

func StripLeftDashes

func StripLeftDashes(s string) string

StripLeftDashes removes all leading dash characters ('-') from the input string. This function is useful for sanitizing command-line arguments or any other input that may contain leading dashes, such as flags or options.

Parameters:

s (string): The input string from which to strip leading dashes.

Returns:

string: A new string with all leading dashes removed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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