formatters

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanAndFormatText

func CleanAndFormatText(input string) string

CleanAndFormatText processes the input string by removing escape characters, trimming quotes, and cleaning up whitespace. It returns a formatted string, either joining two non-empty lines with a comma or joining multiple lines with spaces.

func CleanTextSelect

func CleanTextSelect(s *goquery.Selection) string

CleanTextSelect extracts the text from a goquery selection, trims whitespace, and returns the cleaned string.

func CleanTextStr

func CleanTextStr(s string) string

CleanTextStr trims leading and trailing whitespace from the input string and returns the cleaned string.

func CookieDomain

func CookieDomain(url string) string

CookieDomain extracts and returns the base domain from a given URL by removing the protocol (http/https) and any paths or subdomains. It handles common domain extensions such as .com, .org, and .net.

func FormatResultsAsJson

func FormatResultsAsJson(mods types.ModInfo) (string, error)

FormatResultsAsJson takes a ModInfo object, formats it as a pretty-printed JSON string, and returns the result. If marshalling fails, it returns an error.

func PrintJson

func PrintJson(data string)

PrintJson prints a given JSON-formatted string to the standard output.

func PrintPrettyJson

func PrintPrettyJson(data string, useAltColors ...bool) error

PrintPrettyJson takes a JSON string, unmarshals it into an object, and prints it with pretty formatting. Optionally, alternate colors can be used for keys and strings if useAltColors is provided and set to true. Returns an error if JSON unmarshalling or formatting fails.

func RemoveHTTPPrefix

func RemoveHTTPPrefix(url string) string

RemoveHTTPPrefix removes the http or https prefix from a given URL and returns the modified string.

func StrToInt

func StrToInt(input string) (int64, error)

StrToInt converts a string to an int64. It returns the parsed integer and an error if the conversion fails.

Types

This section is empty.

Jump to

Keyboard shortcuts

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