util

package
v5.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Overview

Package util provides simple utility functions usable in all modules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeautifulName

func BeautifulName(uglyName string) string

BeautifulName makes the ugly name beautiful by replacing _ with spaces and using title case

func CanonicalName

func CanonicalName(name string) string

CanonicalName returns the canonical form of the name. A name is canonical if it is lowercase, all left and right whitespace is trimmed and all spaces are replaced with underscores.

func DefaultString

func DefaultString(s, d string) string

DefaultString returns d if s is an empty string, s otherwise.

func SanitizedName

func SanitizedName(unsafeName string) string

SanitizedName is unsafeName with all unsafe characters removed.

func StringID

func StringID(s string) string

StringID sanitizes the string and makes it more suitable for the id attribute in HTML.

func TernaryConditionString

func TernaryConditionString(cond bool, thenBranch, elseBranch string) string

TernaryConditionString is an approximation of an expression like (cond ? thenBranch : elseBranch) from other programming languages. There is no real need for this function, I just felt the urge to add it.

func ValidURL added in v5.3.1

func ValidURL(s string) bool

ValidURL is true if s is a valid absolute URL.

Types

This section is empty.

Directories

Path Synopsis
Package line provides a datatype for text lines that are generated by package tag.
Package line provides a datatype for text lines that are generated by package tag.

Jump to

Keyboard shortcuts

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