google

package
v0.0.0-...-1a28a91 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TemplateFunctions = template.FuncMap{
	"title":         SpaceSeparatedTitle,
	"replace":       strings.Replace,
	"replaceAll":    strings.ReplaceAll,
	"camelize":      Camelize,
	"underscore":    Underscore,
	"plural":        Plural,
	"contains":      strings.Contains,
	"join":          strings.Join,
	"lower":         strings.ToLower,
	"upper":         strings.ToUpper,
	"hasSuffix":     strings.HasSuffix,
	"dict":          wrapMultipleParams,
	"format2regex":  Format2Regex,
	"hasPrefix":     strings.HasPrefix,
	"sub":           subtract,
	"plus":          plus,
	"firstSentence": FirstSentence,
	"trimTemplate":  TrimTemplate,
}

Functions

func Camelize

func Camelize(term string, firstLetter string) string

func Concat

func Concat[T any](S1 []T, S2 []T) (ret []T)

Concat two slices

func Diff

func Diff(S1, S2 []string) []string

difference returns the elements in `S1` that aren't in `S2`.

func FirstSentence

func FirstSentence(text string) string

Returns all the characters up until the period (.) or returns text unchanged if there is no period.

func Format2Regex

func Format2Regex(format string) string

Transforms a format string with field markers to a regex string with capture groups. For instance,

projects/{{project}}/global/networks/{{name}}

is transformed to

projects/(?P<project>[^/]+)/global/networks/(?P<name>[^/]+)

Values marked with % are URL-encoded, and will match any number of /'s. Note: ?P indicates a Python-compatible named capture group. Named groups aren't common in JS-based regex flavours, but are in Perl-based ones

func Plural

func Plural(source string) string

Returns the plural form of a word

func Reject

func Reject[T any](S []T, test func(T) bool) (ret []T)

Returns a new slice containing all of the elements for which the test function returns false in the original slice

func Select

func Select[T any](S []T, test func(T) bool) (ret []T)

Returns a new slice containing all of the elements for which the test function returns true in the original slice

func SpaceSeparated

func SpaceSeparated(source string) string

Converts from PascalCase to Space Separated For example, converts "AccessApproval" to "Access approval"

func SpaceSeparatedTitle

func SpaceSeparatedTitle(source string) string

Converts a string to space-separated capitalized words

func TrimTemplate

func TrimTemplate(templatePath string, e any) string

Temporary function to simulate how Ruby MMv1's lines() function works for nested documentation. Can replace with normal "template" after switchover

func Underscore

func Underscore(source string) string

// Helper class to process and mutate strings. class StringUtils Converts string from camel case to underscore

Types

type YamlValidator

type YamlValidator struct{}

A helper class to validate contents coming from YAML files.

func (*YamlValidator) Parse

func (v *YamlValidator) Parse(content []byte, obj interface{}, yamlPath string)

Jump to

Keyboard shortcuts

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