stringx

package
v0.3.23 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	// DefaultBuilderSize is the default size of the Builder in bytes.
	DefaultBuilderSize = 1024

	// MaxBuilderSize is the maximum size of the Builder in bytes.
	MaxBuilderSize = 4096
)

Variables

View Source
var ToFloatOr = ToFloat64Or

ToFloatOr parses s as a float64 or returns defaultValue.

Parameters:

  • s: the string to parse.
  • defaultValue: the default value.

Returns:

  • float64: the parsed float64 or defaultValue.
View Source
var (
	Verbose = false
)

Verbose enables console output for functions that have counterparts in Go's standard packages.

Functions

func AsciiEqualFold

func AsciiEqualFold(s, t []byte) bool

AsciiEqualFold is a specialization of bytes.EqualFold for use when s is all ASCII (but may contain non-letters) and contains no special-folding letters. See comments on FoldFunc.

Parameters:

  • s: the source bytes.
  • t: the target bytes.

Returns:

  • bool: true if the strings are equal under folding.

func Between

func Between(s, left, right string) string

Between extracts a string between left and right strings.

Parameters:

  • s: the source string.
  • left: the left delimiter.
  • right: the right delimiter.

Returns:

  • string: the substring between left and right.
Example

import "strings"

eg(1, Between("<a>foo</a>", "<a>", "</a>"))
eg(2, Between("<a>foo</a></a>", "<a>", "</a>"))
eg(3, Between("<a><a>foo</a></a>", "<a>", "</a>"))
eg(4, Between("<a><a>foo</a></a>", "<a>", "</a>"))
eg(5, Between("<a>foo", "<a>", "</a>"))
eg(6, Between("Some strings } are very {weird}, dont you think?", "{", "}"))
eg(7, Between("This is ateststring", "", "test"))
eg(8, Between("This is ateststring", "test", ""))
Output:
1: foo
2: foo
3: <a>foo
4: <a>foo
5:
6: weird
7: This is a
8: string

func BetweenF

func BetweenF(left, right string) func(string) string

BetweenF is the filter form for Between.

Parameters:

  • left: the left delimiter.
  • right: the right delimiter.

Returns:

  • func(string) string: a function that extracts the substring.
Example
eg(1, Pipe("abc", BetweenF("a", "c")))
Output:
1: b

func Camelize

func Camelize(s string) string

Camelize returns a new string which removes any underscores or dashes and converts a string into camel casing.

Parameters:

  • s: the string to camelize.

Returns:

  • string: the camelized string.
Example
eg(1, Camelize("data_rate"))
eg(2, Camelize("background-color"))
eg(3, Camelize("-moz-something"))
eg(4, Camelize("_car_speed_"))
eg(5, Camelize("yes_we_can"))
Output:
1: dataRate
2: backgroundColor
3: MozSomething
4: CarSpeed
5: yesWeCan

func Capitalize

func Capitalize(s string) string

Capitalize uppercases the first char of s and lowercases the rest.

Parameters:

  • s: the string to capitalize.

Returns:

  • string: the capitalized string.
Example
eg(1, Capitalize("abc"))
eg(2, Capitalize("ABC"))
Output:
1: Abc
2: Abc

func CharAt

func CharAt(s string, index int) string

CharAt returns a string from the character at the specified position.

Parameters:

  • s: the source string.
  • index: the position.

Returns:

  • string: the character at the specified position.
Example
eg(1, CharAt("abc", 1))
eg(2, CharAt("", -1))
eg(3, CharAt("", 0))
eg(4, CharAt("", 10))
eg(5, CharAt("abc", -1))
eg(6, CharAt("abc", 10))
Output:
1: b
2:
3:
4:
5:
6:

func CharAtF

func CharAtF(index int) func(string) string

CharAtF is the filter form of CharAt.

Parameters:

  • index: the position.

Returns:

  • func(string) string: a function that returns the character at the specified position.
Example
eg(1, Pipe("abc", CharAtF(1)))
Output:
1: b

func ChompLeft

func ChompLeft(s, prefix string) string

ChompLeft removes prefix at the start of a string.

Parameters:

  • s: the source string.
  • prefix: the prefix to remove.

Returns:

  • string: the string with the prefix removed.
Example
eg(1, ChompLeft("foobar", "foo"))
eg(2, ChompLeft("foobar", "bar"))
eg(3, ChompLeft("", "foo"))
eg(4, ChompLeft("", ""))
eg(5, ChompLeft("foo", ""))
Output:
1: bar
2: foobar
3:
4:
5: foo

func ChompLeftF

func ChompLeftF(prefix string) func(string) string

ChompLeftF is the filter form of ChompLeft.

Parameters:

  • prefix: the prefix to remove.

Returns:

  • func(string) string: a function that removes the prefix.
Example
eg(1, Pipe("abc", ChompLeftF("ab")))
Output:
1: c

func ChompRight

func ChompRight(s, suffix string) string

ChompRight removes suffix from end of s.

Parameters:

  • s: the source string.
  • suffix: the suffix to remove.

Returns:

  • string: the string with the suffix removed.
Example
eg(1, ChompRight("foobar", "foo"))
eg(2, ChompRight("foobar", "bar"))
eg(3, ChompRight("", "foo"))
eg(4, ChompRight("", ""))
Output:
1: foobar
2: foo
3:
4:

func ChompRightF

func ChompRightF(suffix string) func(string) string

ChompRightF is the filter form of ChompRight.

Parameters:

  • suffix: the suffix to remove.

Returns:

  • func(string) string: a function that removes the suffix.
Example
eg(1, Pipe("abc", ChompRightF("bc")))
Output:
1: a

func Classify

func Classify(s string) string

Classify returns a camelized string with the first letter upper cased.

Parameters:

  • s: the string to classify.

Returns:

  • string: the classified string.
Example
eg(1, Classify("data_rate"))
eg(2, Classify("background-color"))
eg(3, Classify("-moz-something"))
eg(4, Classify("_car_speed_"))
eg(5, Classify("yes_we_can"))
Output:
1: DataRate
2: BackgroundColor
3: MozSomething
4: CarSpeed
5: YesWeCan

func ClassifyF

func ClassifyF(s string) func(string) string

ClassifyF is the filter form of Classify.

Parameters:

  • s: the string to classify.

Returns:

  • func(string) string: a function that classifies the string.

func Clean

func Clean(s string) string

Clean compresses all adjacent whitespace to a single space and trims s.

Parameters:

  • s: the string to clean.

Returns:

  • string: the cleaned string.
Example
eg(1, Clean("clean"))
eg(2, Clean(""))
eg(3, Clean(" please\t    clean \t \n  me "))
Output:
1: clean
2:
3: please clean me

func Dasherize

func Dasherize(s string) string

Dasherize converts a camel cased string into a string delimited by dashes.

Parameters:

  • s: the string to dasherize.

Returns:

  • string: the dasherized string.
Example
eg(1, Dasherize("dataRate"))
eg(2, Dasherize("CarSpeed"))
eg(3, Dasherize("yesWeCan"))
eg(4, Dasherize(""))
eg(5, Dasherize("ABC"))
Output:
1: data-rate
2: -car-speed
3: yes-we-can
4:
5: -a-b-c

func DecodeHTMLEntities

func DecodeHTMLEntities(s string) string

DecodeHTMLEntities decodes HTML entities into their proper string representation. DecodeHTMLEntities is an alias for html.UnescapeString.

Parameters:

  • s: the string to decode.

Returns:

  • string: the decoded string.
Example
eg(1, DecodeHTMLEntities("Ken Thompson &amp; Dennis Ritchie"))
eg(2, DecodeHTMLEntities("3 &lt; 4"))
eg(3, DecodeHTMLEntities("http:&#47;&#47;"))
Output:
1: Ken Thompson & Dennis Ritchie
2: 3 < 4
3: http://

func DotCase added in v0.3.9

func DotCase(s string) string

DotCase converts an arbitrary string to a dot-case string (e.g., service.name).

Parameters:

  • s: the string to convert.

Returns:

  • string: the dot-cased string.

func EnsurePrefix

func EnsurePrefix(s, prefix string) string

EnsurePrefix ensures s starts with prefix.

Parameters:

  • s: the source string.
  • prefix: the prefix to ensure.

Returns:

  • string: the string with the prefix.
Example
eg(1, EnsurePrefix("foobar", "foo"))
eg(2, EnsurePrefix("bar", "foo"))
eg(3, EnsurePrefix("", ""))
eg(4, EnsurePrefix("foo", ""))
eg(5, EnsurePrefix("", "foo"))
Output:
1: foobar
2: foobar
3:
4: foo
5: foo

func EnsurePrefixF

func EnsurePrefixF(prefix string) func(string) string

EnsurePrefixF is the filter form of EnsurePrefix.

Parameters:

  • prefix: the prefix to ensure.

Returns:

  • func(string) string: a function that ensures the prefix.
Example
eg(1, Pipe("dir", EnsurePrefixF("./")))
Output:
1: ./dir

func EnsureSuffix

func EnsureSuffix(s, suffix string) string

EnsureSuffix ensures s ends with suffix.

Parameters:

  • s: the source string.
  • suffix: the suffix to ensure.

Returns:

  • string: the string with the suffix.
Example
eg(1, EnsureSuffix("foobar", "bar"))
eg(2, EnsureSuffix("foo", "bar"))
eg(3, EnsureSuffix("", ""))
eg(4, EnsureSuffix("foo", ""))
eg(5, EnsureSuffix("", "bar"))
Output:
1: foobar
2: foobar
3:
4: foo
5: bar

func EnsureSuffixF

func EnsureSuffixF(suffix string) func(string) string

EnsureSuffixF is the filter form of EnsureSuffix.

Parameters:

  • suffix: the suffix to ensure.

Returns:

  • func(string) string: a function that ensures the suffix.

func EnumValueName

func EnumValueName(s string) string

EnumValueName derives the camel-cased enum value name. See protoc v3.8.0: src/google/protobuf/descriptor.cc:297-313

Parameters:

  • s: the enum value.

Returns:

  • string: the camel-cased enum value name.

func EqualFoldRight

func EqualFoldRight(s, t []byte) bool

EqualFoldRight is a specialization of bytes.EqualFold when s is known to be all ASCII (including punctuation), but contains an 's', 'S', 'k', or 'K', requiring a Unicode fold on the bytes in t. See comments on FoldFunc.

Parameters:

  • s: the source bytes.
  • t: the target bytes.

Returns:

  • bool: true if the strings are equal under folding.

func EscapeHTML

func EscapeHTML(s string) string

EscapeHTML is an alias for html.EscapeString.

Parameters:

  • s: the string to escape.

Returns:

  • string: the escaped string.

func FoldFunc

func FoldFunc(s []byte) func(s, t []byte) bool

FoldFunc returns one of four different case folding equivalence functions, from most general (and slow) to fastest:

  1. bytes.EqualFold, if the key s contains any non-ASCII UTF-8
  2. EqualFoldRight, if s contains special folding ASCII ('k', 'K', 's', 'S')
  3. AsciiEqualFold, no special, but includes non-letters (including _)
  4. SimpleLetterEqualFold, no specials, no non-letters.

The letters S and K are special because they map to 3 runes, not just 2:

  • S maps to s and to U+017F 'ſ' Latin small letter long s
  • k maps to K and to U+212A 'K' Kelvin sign

See https://play.golang.org/p/tTxjOc0OGo

The returned function is specialized for matching against s and should only be given s. It's not curried for performance reasons.

Parameters:

  • s: the byte slice to match against.

Returns:

  • func(s, t []byte) bool: a case folding function.

func GetBuilder

func GetBuilder() *strings.Builder

GetBuilder retrieves a strings.Builder from the pool.

Returns:

  • *strings.Builder: a Builder from the pool.

func GoCamelCase

func GoCamelCase(s string) string

GoCamelCase camel-cases a protobuf name for use as a Go identifier.

If there is an interior underscore followed by a lower case letter, drop the underscore and convert the letter to upper case.

Parameters:

  • s: the string to convert.

Returns:

  • string: the camel-cased string.

func GoSanitized

func GoSanitized(s string) string

GoSanitized converts a string to a valid Go identifier.

Parameters:

  • s: the string to convert.

Returns:

  • string: a valid Go identifier.

func Humanize

func Humanize(s string) string

Humanize transforms s into a human friendly form.

Parameters:

  • s: the string to humanize.

Returns:

  • string: the humanized string.
Example
eg(1, Humanize("the_humanize_string_method"))
eg(2, Humanize("ThehumanizeStringMethod"))
eg(3, Humanize("the humanize string method"))
Output:
1: The humanize string method
2: Thehumanize string method
3: The humanize string method

func Iif

func Iif(condition bool, truthy string, falsey string) string

Iif is short for immediate if. If condition is true return truthy else falsey.

Parameters:

  • condition: the condition.
  • truthy: the value to return if condition is true.
  • falsey: the value to return if condition is false.

Returns:

  • string: truthy or falsey.
Example
eg(1, Iif(true, "T", "F"))
eg(2, Iif(false, "T", "F"))
Output:
1: T
2: F

func IndexOf

func IndexOf(s string, needle string, start int) int

IndexOf finds the index of needle in s starting from start.

Parameters:

  • s: the source string.
  • needle: the substring to find.
  • start: the starting index.

Returns:

  • int: the index of needle, or -1 if not found.
Example
eg(1, IndexOf("abcdef", "a", 0))
eg(2, IndexOf("abcdef", "a", 3))
eg(3, IndexOf("abcdef", "a", -2))
eg(4, IndexOf("abcdef", "a", 10))
eg(5, IndexOf("", "a", 0))
eg(6, IndexOf("abcdef", "", 2))
eg(7, IndexOf("abcdef", "", 1000))
Output:
1: 0
2: -1
3: -1
4: -1
5: -1
6: 2
7: 6

func Indices

func Indices(str, substr string) []int

Indices returns all starting indices of substr in str.

Parameters:

  • str: the source string.
  • substr: the substring to find.

Returns:

  • []int: all starting indices of substr.

func IsAllBlank

func IsAllBlank[S ~string](ss ...S) bool

IsAllBlank checks if all of the CharSequences are empty ("") or whitespace only.

Parameters:

  • ss: the strings to check.

Returns:

  • bool: true if all strings are blank.

func IsAllEmpty

func IsAllEmpty[S ~string](ss ...S) bool

IsAllEmpty checks if all of the strings are empty ("").

Parameters:

  • ss: the strings to check.

Returns:

  • bool: true if all strings are empty.

func IsAlpha

func IsAlpha(s string) bool

IsAlpha returns true if a string contains only letters from ASCII (a-z,A-Z). Other letters from other languages are not supported.

Parameters:

  • s: the string to check.

Returns:

  • bool: true if the string is alphabetic.
Example
eg(1, IsAlpha("afaf"))
eg(2, IsAlpha("FJslfjkasfs"))
eg(3, IsAlpha("áéúóúÁÉÍÓÚãõÃÕàèìòùÀÈÌÒÙâêîôûÂÊÎÔÛäëïöüÄËÏÖÜçÇ"))
eg(4, IsAlpha("adflj43faljsdf"))
eg(5, IsAlpha("33"))
eg(6, IsAlpha("TT....TTTafafetstYY"))
eg(7, IsAlpha("-áéúóúÁÉÍÓÚãõÃÕàèìòùÀÈÌÒÙâêîôûÂÊÎÔÛäëïöüÄËÏÖÜçÇ"))
Output:
1: true
2: true
3: true
4: false
5: false
6: false
7: false

func IsAlphaNumeric

func IsAlphaNumeric(s string) bool

IsAlphaNumeric returns true if a string contains letters and digits.

Parameters:

  • s: the string to check.

Returns:

  • bool: true if the string is alphanumeric.
Example
eg(1, IsAlphaNumeric("afaf35353afaf"))
eg(2, IsAlphaNumeric("FFFF99fff"))
eg(3, IsAlphaNumeric("99"))
eg(4, IsAlphaNumeric("afff"))
eg(5, IsAlphaNumeric("Infinity"))
eg(6, IsAlphaNumeric("áéúóúÁÉÍÓÚãõÃÕàèìòùÀÈÌÒÙâêîôûÂÊÎÔÛäëïöüÄËÏÖÜçÇ1234567890"))
eg(7, IsAlphaNumeric("-Infinity"))
eg(8, IsAlphaNumeric("-33"))
eg(9, IsAlphaNumeric("aaff.."))
eg(10, IsAlphaNumeric(".áéúóúÁÉÍÓÚãõÃÕàèìòùÀÈÌÒÙâêîôûÂÊÎÔÛäëïöüÄËÏÖÜçÇ1234567890"))
Output:
1: true
2: true
3: true
4: true
5: true
6: true
7: false
8: false
9: false
10: false

func IsAnyBlank

func IsAnyBlank[S ~string](ss ...S) bool

IsAnyBlank checks if any of the string are empty ("") or whitespace only.

Parameters:

  • ss: the strings to check.

Returns:

  • bool: true if any string is blank.

func IsAnyEmpty

func IsAnyEmpty[S ~string](ss ...S) bool

IsAnyEmpty checks if any of the strings are empty ("").

Parameters:

  • ss: the strings to check.

Returns:

  • bool: true if any string is empty.

func IsBlank

func IsBlank[S ~string](s S) bool

IsBlank checks if a string is empty ("") or whitespace only.

Parameters:

  • s: the string to check.

Returns:

  • bool: true if the string is blank.

func IsEmpty

func IsEmpty[S ~string](s S) bool

IsEmpty returns true if the string is solely composed of whitespace.

Parameters:

  • s: the string to check.

Returns:

  • bool: true if the string is empty.
Example
eg(1, IsEmpty(" "))
eg(2, IsEmpty("\t\t\t   "))
eg(3, IsEmpty("\t\n "))
eg(4, IsEmpty("hi"))
Output:
1: true
2: true
3: true
4: false

func IsLower

func IsLower(s string) bool

IsLower returns true if s is comprised of all lower case characters.

Parameters:

  • s: the string to check.

Returns:

  • bool: true if the string is all lowercase.
Example
eg(1, IsLower("a"))
eg(2, IsLower("A"))
eg(3, IsLower("abc"))
eg(4, IsLower("aBc"))
eg(5, IsLower("áéúóúãõàèìòùâêîôûäëïöüç"))
eg(6, IsLower("hi jp"))
eg(7, IsLower("ÁÉÍÓÚÃÕÀÈÌÒÙÂÊÎÔÛÄËÏÖÜÇ"))
eg(8, IsLower("áéúóúãõàèìòùâêîôûäëïöüçÁ"))
eg(9, IsLower("áéúóúãõàèìòùâêîôû äëïöüç"))
Output:
1: true
2: false
3: true
4: false
5: true
6: false
7: false
8: false
9: false

func IsNotBlank

func IsNotBlank[S ~string](s S) bool

IsNotBlank checks if a string is not empty ("") and not whitespace only.

Parameters:

  • s: the string to check.

Returns:

  • bool: true if the string is not blank.

func IsNotEmpty

func IsNotEmpty[S ~string](s S) bool

IsNotEmpty checks if a string is not empty ("").

Parameters:

  • s: the string to check.

Returns:

  • bool: true if the string is not empty.

func IsNumeric

func IsNumeric(s string) bool

IsNumeric returns true if a string contains only digits from 0-9. Other digits not in Latin (such as Arabic) are not currently supported.

Parameters:

  • s: the string to check.

Returns:

  • bool: true if the string is numeric.
Example
eg(1, IsNumeric("3"))
eg(2, IsNumeric("34.22"))
eg(3, IsNumeric("-22.33"))
eg(4, IsNumeric("NaN"))
eg(5, IsNumeric("Infinity"))
eg(6, IsNumeric("-Infinity"))
eg(7, IsNumeric("JP"))
eg(8, IsNumeric("-5"))
eg(9, IsNumeric("00099242424"))
Output:
1: true
2: false
3: false
4: false
5: false
6: false
7: false
8: false
9: true

func IsUpper

func IsUpper(s string) bool

IsUpper returns true if s contains all upper case characters.

Parameters:

  • s: the string to check.

Returns:

  • bool: true if the string is all uppercase.
Example
eg(1, IsUpper("a"))
eg(2, IsUpper("A"))
eg(3, IsUpper("ABC"))
eg(4, IsUpper("aBc"))
eg(5, IsUpper("áéúóúãõàèìòùâêîôûäëïöüç"))
eg(6, IsUpper("HI JP"))
eg(7, IsUpper("ÁÉÍÓÚÃÕÀÈÌÒÙÂÊÎÔÛÄËÏÖÜÇ"))
eg(8, IsUpper("áéúóúãõàèìòùâêîôûäëïöüçÁ"))
eg(9, IsUpper("ÁÉÍÓÚÃÕÀÈÌÒÙÂÊÎ ÔÛÄËÏÖÜÇ"))
Output:
1: false
2: true
3: true
4: false
5: false
6: false
7: true
8: false
9: false

func IsValidNumber

func IsValidNumber(s string) bool

IsValidNumber reports whether s is a valid number.

Parameters:

  • s: the string to check.

Returns:

  • bool: true if s is a valid number.

func JSONCamelCase

func JSONCamelCase(s string) string

JSONCamelCase converts a snake_case identifier to a camelCase identifier, according to the protobuf JSON specification.

Parameters:

  • s: the string to convert.

Returns:

  • string: the camel-cased string.

func JSONSnakeCase

func JSONSnakeCase(s string) string

JSONSnakeCase converts a camelCase identifier to a snake_case identifier, according to the protobuf JSON specification.

Parameters:

  • s: the string to convert.

Returns:

  • string: the snake-cased string.

func JoinBool

func JoinBool[E ~bool](es []E, sep string) string

JoinBool joins a slice of booleans into a string.

Parameters:

  • es: the slice of booleans.
  • sep: the separator.

Returns:

  • string: the joined string.

func JoinFloat

func JoinFloat[E constraints.Float](es []E, sep string) string

JoinFloat joins a slice of floats into a string.

Parameters:

  • es: the slice of floats.
  • sep: the separator.

Returns:

  • string: the joined string.

func JoinInt

func JoinInt[E constraints.Signed](es []E, sep string) string

JoinInt joins a slice of signed integers into a string.

Parameters:

  • es: the slice of integers.
  • sep: the separator.

Returns:

  • string: the joined string.

func JoinUint

func JoinUint[E constraints.Unsigned](es []E, sep string) string

JoinUint joins a slice of unsigned integers into a string.

Parameters:

  • es: the slice of unsigned integers.
  • sep: the separator.

Returns:

  • string: the joined string.

func KebabCase added in v0.3.9

func KebabCase(s string) string

KebabCase converts an arbitrary string to a kebab-case string that complies with domain name specifications.

Parameters:

  • s: the string to convert.

Returns:

  • string: the kebab-cased string.

func Left

func Left(s string, n int) string

Left returns the left substring of length n.

Parameters:

  • s: the source string.
  • n: the length.

Returns:

  • string: the left substring.
Example
eg(1, Left("abcdef", 0))
eg(2, Left("abcdef", 1))
eg(3, Left("abcdef", 4))
eg(4, Left("abcdef", -2))
Output:
1:
2: a
3: abcd
4: ef

func LeftF

func LeftF(n int) func(string) string

LeftF is the filter form of Left.

Parameters:

  • n: the length.

Returns:

  • func(string) string: a function that returns the left substring.

func LeftOf

func LeftOf(s string, needle string) string

LeftOf returns the substring left of needle.

Parameters:

  • s: the source string.
  • needle: the delimiter.

Returns:

  • string: the substring left of needle.
Example
eg(1, LeftOf("abcdef", "def"))
eg(2, LeftOf("abcdef", "abc"))
eg(3, LeftOf("abcdef", ""))
eg(4, LeftOf("", "abc"))
eg(5, LeftOf("abcdef", "xyz"))
Output:
1: abc
2:
3: abcdef
4:
5:

func Letters

func Letters(s string) []string

Letters returns an array of runes as strings so it can be indexed into.

Parameters:

  • s: the source string.

Returns:

  • []string: an array of runes as strings.

func Lines

func Lines(s string) []string

Lines converts windows newlines to unix newlines then converts to an array of lines.

Parameters:

  • s: the source string.

Returns:

  • []string: an array of lines.
Example
eg(1, Lines("a\r\nb\nc\r\n"))
eg(2, Lines("a\r\nb\nc\r\nd"))
Output:
1: [a b c ]
2: [a b c d]

func Map

func Map(arr []string, iterator func(string) string) []string

Map maps an array's items through an iterator.

Parameters:

  • arr: the array to map.
  • iterator: the mapping function.

Returns:

  • []string: the mapped array.

func MapEntryName

func MapEntryName(s string) string

MapEntryName derives the name of the map entry message given the field name. See protoc v3.8.0: src/google/protobuf/descriptor.cc:254-276,6057

Parameters:

  • s: the field name.

Returns:

  • string: the map entry message name.

func Match

func Match(s, pattern string) bool

Match returns true if pattern matches the string.

Parameters:

  • s: the source string.
  • pattern: the regexp pattern.

Returns:

  • bool: true if pattern matches.
Example
eg(1, Match("foobar", `^fo.*r$`))
eg(2, Match("foobar", `^fo.*x$`))
eg(3, Match("", `^fo.*x$`))
Output:
1: true
2: false
3: false

func MatchAll

func MatchAll(str string, pattern string) []string

MatchAll returns all matches of pattern in str.

Parameters:

  • str: the source string.
  • pattern: the regexp pattern.

Returns:

  • []string: all matches.

func Max

func Max[S ~string](a, b S) S

Max returns the greater of a and b.

Parameters:

  • a: the first string.
  • b: the second string.

Returns:

  • S: the greater string.

func Min

func Min[S ~string](a, b S) S

Min returns the lesser of a and b.

Parameters:

  • a: the first string.
  • b: the second string.

Returns:

  • S: the lesser string.

func Pad

func Pad(s, c string, n int) string

Pad pads string s on both sides with c until it has length of n.

Parameters:

  • s: the string to pad.
  • c: the padding character.
  • n: the desired length.

Returns:

  • string: the padded string.
Example
eg(1, Pad("hello", "x", 5))
eg(2, Pad("hello", "x", 10))
eg(3, Pad("hello", "x", 11))
eg(4, Pad("hello", "x", 6))
eg(5, Pad("hello", "x", 1))
Output:
1: hello
2: xxxhelloxx
3: xxxhelloxxx
4: xhello
5: hello

func PadF

func PadF(c string, n int) func(string) string

PadF is the filter form of Pad.

Parameters:

  • c: the padding character.
  • n: the desired length.

Returns:

  • func(string) string: a function that pads the string.

func PadLeft

func PadLeft(s, c string, n int) string

PadLeft pads s on left side with c until it has length of n.

Parameters:

  • s: the string to pad.
  • c: the padding character.
  • n: the desired length.

Returns:

  • string: the left-padded string.
Example
eg(1, PadLeft("hello", "x", 5))
eg(2, PadLeft("hello", "x", 10))
eg(3, PadLeft("hello", "x", 11))
eg(4, PadLeft("hello", "x", 6))
eg(5, PadLeft("hello", "x", 1))
Output:
1: hello
2: xxxxxhello
3: xxxxxxhello
4: xhello
5: hello

func PadLeftF

func PadLeftF(c string, n int) func(string) string

PadLeftF is the filter form of PadLeft.

Parameters:

  • c: the padding character.
  • n: the desired length.

Returns:

  • func(string) string: a function that left-pads the string.

func PadRight

func PadRight(s, c string, n int) string

PadRight pads s on right side with c until it has length of n.

Parameters:

  • s: the string to pad.
  • c: the padding character.
  • n: the desired length.

Returns:

  • string: the right-padded string.
Example
eg(1, PadRight("hello", "x", 5))
eg(2, PadRight("hello", "x", 10))
eg(3, PadRight("hello", "x", 11))
eg(4, PadRight("hello", "x", 6))
eg(5, PadRight("hello", "x", 1))
Output:
1: hello
2: helloxxxxx
3: helloxxxxxx
4: hellox
5: hello

func PadRightF

func PadRightF(c string, n int) func(string) string

PadRightF is the filter form of PadRight.

Parameters:

  • c: the padding character.
  • n: the desired length.

Returns:

  • func(string) string: a function that right-pads the string.

func Pipe

func Pipe(s string, funcs ...func(string) string) string

Pipe pipes s through one or more string filters.

Parameters:

  • s: the source string.
  • funcs: the filter functions.

Returns:

  • string: the piped string.
Example
eg(1, Pipe("\nabcdef   \n", Clean, BetweenF("a", "f"), ChompLeftF("bc")))
Output:
1: de

func PutBuilder

func PutBuilder(buf *strings.Builder)

PutBuilder returns a strings.Builder to the pool.

Parameters:

  • buf: the Builder to return.

func QuoteItems

func QuoteItems(arr []string) []string

QuoteItems quotes all items in array, mostly for debugging.

Parameters:

  • arr: the array to quote.

Returns:

  • []string: the quoted items.

func Remove

func Remove(s string, chars string) string

Remove takes a string candidate and a string of chars to remove from the candidate.

Parameters:

  • s: the source string.
  • chars: the characters to remove.

Returns:

  • string: the string with characters removed.

func ReplaceF

func ReplaceF(old, new string, n int) func(string) string

ReplaceF is the filter form of strings.Replace.

Parameters:

  • old: the substring to replace.
  • new: the replacement substring.
  • n: the number of replacements.

Returns:

  • func(string) string: a function that replaces substrings.
Example
eg(1, Pipe("abcdefab", ReplaceF("ab", "x", -1)))
eg(2, Pipe("abcdefab", ReplaceF("ab", "x", 1)))
eg(3, Pipe("abcdefab", ReplaceF("ab", "x", 0)))
Output:
1: xcdefx
2: xcdefab
3: abcdefab

func ReplaceFunc

func ReplaceFunc(str string, f func(rune) string) string

ReplaceFunc replaces each rune in str with the result of f.

Parameters:

  • str: the source string.
  • f: the replacement function.

Returns:

  • string: the replaced string.

func ReplacePattern

func ReplacePattern(s, pattern, repl string) string

ReplacePattern replaces string with regexp string. ReplacePattern returns a copy of src, replacing matches of the Regexp with the replacement string repl. Inside repl, $ signs are interpreted as in Expand, so for instance $1 represents the text of the first submatch.

Parameters:

  • s: the source string.
  • pattern: the regexp pattern.
  • repl: the replacement string.

Returns:

  • string: the replaced string.
Example
eg(1, ReplacePattern("aabbcc", `a`, "x"))
Output:
1: xxbbcc

func ReplacePatternF

func ReplacePatternF(pattern, repl string) func(string) string

ReplacePatternF is the filter form of ReplacePattern.

Parameters:

  • pattern: the regexp pattern.
  • repl: the replacement string.

Returns:

  • func(string) string: a function that replaces patterns.
Example
eg(1, Pipe("aabbcc", ReplacePatternF(`a`, "x")))
Output:
1: xxbbcc

func Reverse

func Reverse(s string) string

Reverse reverses a string.

Parameters:

  • s: the string to reverse.

Returns:

  • string: the reversed string.
Example
eg(1, Reverse("abc"))
eg(2, Reverse("中文"))
Output:
1: cba
2: 文中
func Right(s string, n int) string

Right returns the right substring of length n.

Parameters:

  • s: the source string.
  • n: the length.

Returns:

  • string: the right substring.
Example
eg(1, Right("abcdef", 0))
eg(2, Right("abcdef", 1))
eg(3, Right("abcdef", 4))
eg(4, Right("abcdef", -2))
Output:
1:
2: f
3: cdef
4: ab

func RightF

func RightF(n int) func(string) string

RightF is the filter form of Right.

Parameters:

  • n: the length.

Returns:

  • func(string) string: a function that returns the right substring.
Example
eg(1, Pipe("abcdef", RightF(3)))
Output:
1: def

func RightOf

func RightOf(s string, prefix string) string

RightOf returns the substring to the right of prefix.

Parameters:

  • s: the source string.
  • prefix: the prefix.

Returns:

  • string: the substring to the right of prefix.
Example
eg(1, RightOf("abcdef", "abc"))
eg(2, RightOf("abcdef", "def"))
eg(3, RightOf("abcdef", ""))
eg(4, RightOf("", "abc"))
eg(5, RightOf("abcdef", "xyz"))
Output:
1: def
2:
3: abcdef
4:
5:

func SetTemplateDelimiters

func SetTemplateDelimiters(opening, closing string)

SetTemplateDelimiters sets the delimiters for Template function. Defaults to "{{" and "}}".

Parameters:

  • opening: the opening delimiter.
  • closing: the closing delimiter.

func SimpleLetterEqualFold

func SimpleLetterEqualFold(s, t []byte) bool

SimpleLetterEqualFold is a specialization of bytes.EqualFold for use when s is all ASCII letters (no underscores, etc) and also doesn't contain 'k', 'K', 's', or 'S'. See comments on FoldFunc.

Parameters:

  • s: the source bytes.
  • t: the target bytes.

Returns:

  • bool: true if the strings are equal under folding.

func Slice

func Slice(s string, start, end int) string

Slice slices a string. If end is negative then it is from the end of the string.

Parameters:

  • s: the source string.
  • start: the start index.
  • end: the end index.

Returns:

  • string: the sliced string.

func SliceContains

func SliceContains(slice []string, val string) bool

SliceContains determines whether val is an element in slice.

Parameters:

  • slice: the slice to search.
  • val: the value to find.

Returns:

  • bool: true if val is in the slice.
Example
eg(1, SliceContains([]string{"foo", "bar"}, "foo"))
eg(2, SliceContains(nil, "foo"))
eg(3, SliceContains([]string{"foo", "bar"}, "bah"))
eg(4, SliceContains([]string{"foo", "bar"}, ""))
Output:
1: true
2: false
3: false
4: false

func SliceF

func SliceF(start, end int) func(string) string

SliceF is the filter form of Slice.

Parameters:

  • start: the start index.
  • end: the end index.

Returns:

  • func(string) string: a function that slices the string.

func SliceIndexOf

func SliceIndexOf(slice []string, val string) int

SliceIndexOf gets the index of val in slice. Returns -1 if not found.

Parameters:

  • slice: the slice to search.
  • val: the value to find.

Returns:

  • int: the index of val, or -1 if not found.
Example
eg(1, SliceIndexOf([]string{"foo", "bar"}, "foo"))
eg(2, SliceIndexOf(nil, "foo"))
eg(3, SliceIndexOf([]string{"foo", "bar"}, "bah"))
eg(4, SliceIndexOf([]string{"foo", "bar"}, ""))
eg(5, SliceIndexOf([]string{"foo", "bar"}, "bar"))
Output:
1: 0
2: -1
3: -1
4: -1
5: 1

func Slugify

func Slugify(s string) string

Slugify converts s into a dasherized string suitable for URL segment.

Parameters:

  • s: the string to slugify.

Returns:

  • string: the slugified string.
Example
eg(1, Slugify("foo bar"))
eg(2, Slugify("foo/bar bah"))
eg(3, Slugify("foo-bar--bah"))
Output:
1: foo-bar
2: foobar-bah
3: foo-bar-bah

func StripPunctuation

func StripPunctuation(s string) string

StripPunctuation strips punctuation from string.

Parameters:

  • s: the string to strip.

Returns:

  • string: the string without punctuation.
Example
eg(1, StripPunctuation("My, st[ring] *full* of %punct)"))
Output:
1: My string full of punct

func StripTags

func StripTags(s string, tags ...string) string

StripTags strips all of the html tags or tags specified by the parameters.

Parameters:

  • s: the source string.
  • tags: the tags to strip (optional).

Returns:

  • string: the string with tags stripped.
Example
eg(1, StripTags("<p>just <b>some</b> text</p>"))
eg(2, StripTags("<p>just <b>some</b> text</p>", "p"))
eg(3, StripTags("<a><p>just <b>some</b> text</p></a>", "a", "p"))
eg(4, StripTags("<a><p>just <b>some</b> text</p></a>", "b"))
Output:
1: just some text
2: just <b>some</b> text
3: just <b>some</b> text
4: <a><p>just some text</p></a>

func Substr

func Substr(s string, index int, n int) string

Substr returns a substring of s starting at index of length n.

Parameters:

  • s: the source string.
  • index: the start index.
  • n: the length.

Returns:

  • string: the substring.
Example
eg(1, Substr("abcdef", 2, -1))
eg(2, Substr("abcdef", 2, 0))
eg(3, Substr("abcdef", 2, 1))
eg(4, Substr("abcdef", 2, 3))
eg(5, Substr("abcdef", 2, 4))
eg(6, Substr("abcdef", 2, 100))
eg(7, Substr("abcdef", 0, 1))
Output:
1:
2:
3: c
4: cde
5: cdef
6: cdef
7: a

func SubstrF

func SubstrF(index, n int) func(string) string

SubstrF is the filter form of Substr.

Parameters:

  • index: the start index.
  • n: the length.

Returns:

  • func(string) string: a function that returns the substring.

func Template

func Template(s string, values map[string]interface{}) string

Template is a string template which replaces template placeholders delimited by "{{" and "}}" with values from map. The global delimiters may be set with SetTemplateDelimiters.

Parameters:

  • s: the template string.
  • values: the map of values.

Returns:

  • string: the templated string.
Example
eg(1, Template("Hello {{name}} at {{date-year}}", map[string]interface{}{"name": "foo", "date-year": 2014}))
eg(2, Template("Hello {{name}}", map[string]interface{}{"name": ""}))
SetTemplateDelimiters("{", "}")
eg(3, Template("Hello {name} at {date-year}", map[string]interface{}{"name": "foo", "date-year": 2014}))
Output:
1: Hello foo at 2014
2: Hello
3: Hello foo at 2014

func TemplateDelimiters

func TemplateDelimiters() (opening string, closing string)

TemplateDelimiters returns the opening and closing delimiters for Template.

Returns:

  • opening: the opening delimiter.
  • closing: the closing delimiter.

func TemplateWithDelimiters

func TemplateWithDelimiters(s string, values map[string]interface{}, opening, closing string) string

TemplateWithDelimiters is a string template with user-definable opening and closing delimiters.

Parameters:

  • s: the template string.
  • values: the map of values.
  • opening: the opening delimiter.
  • closing: the closing delimiter.

Returns:

  • string: the templated string.
Example
eg(1, TemplateWithDelimiters("Hello {{name}} at {{date-year}}", map[string]interface{}{"name": "foo", "date-year": 2014}, "{{", "}}"))
eg(2, TemplateWithDelimiters("Hello #{name} at #{date-year}", map[string]interface{}{"name": "foo", "date-year": 2014}, "#{", "}"))
eg(3, TemplateWithDelimiters("Hello (name) at (date-year)", map[string]interface{}{"name": "foo", "date-year": 2014}, "(", ")"))
eg(4, TemplateWithDelimiters("Hello [name] at [date-year]", map[string]interface{}{"name": "foo", "date-year": 2014}, "[", "]"))
eg(5, TemplateWithDelimiters("Hello *name* at *date-year*", map[string]interface{}{"name": "foo", "date-year": 2014}, "*", "*"))
eg(6, TemplateWithDelimiters("Hello $name$ at $date-year$", map[string]interface{}{"name": "foo", "date-year": 2014}, "$", "$"))
Output:
1: Hello foo at 2014
2: Hello foo at 2014
3: Hello foo at 2014
4: Hello foo at 2014
5: Hello foo at 2014
6: Hello foo at 2014

func ToArgv

func ToArgv(s string) []string

ToArgv converts string s into an argv for exec.

Parameters:

  • s: the string to convert.

Returns:

  • []string: the argv.
Example
eg(1, QuoteItems(ToArgv(`GO_ENV=test gosu --watch foo@release "some quoted string 'inside'"`)))
eg(2, QuoteItems(ToArgv(`gosu foo\ bar`)))
eg(3, QuoteItems(ToArgv(`gosu --test="some arg" -w -s a=123`)))
Output:
1: ["GO_ENV=test" "gosu" "--watch" "foo@release" "some quoted string 'inside'"]
2: ["gosu" "foo bar"]
3: ["gosu" "--test=some arg" "-w" "-s" "a=123"]

func ToBool

func ToBool(s string) bool

ToBool fuzzily converts truthy values.

Parameters:

  • s: the string to convert.

Returns:

  • bool: true if the string is truthy.
Example
eg(1, ToBool("true"))
eg(2, ToBool("yes"))
eg(3, ToBool("1"))
eg(4, ToBool("on"))
eg(5, ToBool("false"))
eg(6, ToBool("no"))
eg(7, ToBool("0"))
eg(8, ToBool("off"))
eg(9, ToBool(""))
eg(10, ToBool("?"))
Output:
1: true
2: true
3: true
4: true
5: false
6: false
7: false
8: false
9: false
10: false

func ToBoolOr

func ToBoolOr(s string, defaultValue bool) bool

ToBoolOr parses s as a bool or returns defaultValue.

Parameters:

  • s: the string to parse.
  • defaultValue: the default value.

Returns:

  • bool: the parsed bool or defaultValue.
Example
eg(1, ToBoolOr("foo", true))
eg(2, ToBoolOr("foo", false))
eg(3, ToBoolOr("true", false))
eg(4, ToBoolOr("", true))
Output:
1: true
2: false
3: true
4: true

func ToFloat32Or

func ToFloat32Or(s string, defaultValue float32) float32

ToFloat32Or parses s as a float32 or returns defaultValue on error.

Parameters:

  • s: the string to parse.
  • defaultValue: the default value.

Returns:

  • float32: the parsed float32 or defaultValue.

func ToFloat64Or

func ToFloat64Or(s string, defaultValue float64) float64

ToFloat64Or parses s as a float64 or returns defaultValue.

Parameters:

  • s: the string to parse.
  • defaultValue: the default value.

Returns:

  • float64: the parsed float64 or defaultValue.

func ToIntOr

func ToIntOr(s string, defaultValue int) int

ToIntOr parses s as an int or returns defaultValue.

Parameters:

  • s: the string to parse.
  • defaultValue: the default value.

Returns:

  • int: the parsed int or defaultValue.
Example
eg(1, ToIntOr("foo", 0))
eg(2, ToIntOr("", 1))
eg(3, ToIntOr("100", 0))
eg(4, ToIntOr("-1", 1))
Output:
1: 0
2: 1
3: 100
4: -1

func TrimEnumPrefix

func TrimEnumPrefix(s, prefix string) string

TrimEnumPrefix trims the enum name prefix from an enum value name, where the prefix is all lowercase without underscores. See protoc v3.8.0: src/google/protobuf/descriptor.cc:330-375

Parameters:

  • s: the enum value name.
  • prefix: the prefix to trim.

Returns:

  • string: the trimmed enum value name.

func Underscore

func Underscore(s string) string

Underscore returns converted camel cased string into a string delimited by underscores.

Parameters:

  • s: the string to convert.

Returns:

  • string: the underscored string.
Example
eg(1, Underscore("fooBar"))
eg(2, Underscore("FooBar"))
eg(3, Underscore(""))
eg(4, Underscore("x"))
Output:
1: foo_bar
2: _foo_bar
3:
4: x

func UnescapeHTML

func UnescapeHTML(s string) string

UnescapeHTML is an alias for html.UnescapeString.

Parameters:

  • s: the string to unescape.

Returns:

  • string: the unescaped string.

func WrapHTML

func WrapHTML(s string, tag string, attrs map[string]string) string

WrapHTML wraps s within HTML tag having attributes attrs. Note, WrapHTML does not escape s value.

Parameters:

  • s: the string to wrap.
  • tag: the HTML tag.
  • attrs: the HTML attributes.

Returns:

  • string: the wrapped HTML string.
Example
eg(1, WrapHTML("foo", "span", nil))
eg(2, WrapHTML("foo", "", nil))
eg(3, WrapHTML("foo", "", map[string]string{"class": "bar"}))
Output:
1: <span>foo</span>
2: <div>foo</div>
3: <div class="bar">foo</div>

func WrapHTMLF

func WrapHTMLF(tag string, attrs map[string]string) func(string) string

WrapHTMLF is the filter form of WrapHTML.

Parameters:

  • tag: the HTML tag.
  • attrs: the HTML attributes.

Returns:

  • func(string) string: a function that wraps the string in HTML.
Example
eg(1, Pipe("foo", WrapHTMLF("div", nil)))
Output:
1: <div>foo</div>

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder wraps strings.Builder with nil-check lazy initialization.

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates a new Builder.

Returns:

  • *Builder: a new Builder.

func NewBuilderBuilder

func NewBuilderBuilder(b *strings.Builder) *Builder

NewBuilderBuilder creates a new Builder from an existing strings.Builder.

Parameters:

  • b: the strings.Builder to wrap.

Returns:

  • *Builder: a new Builder.

func (*Builder) Cap

func (b *Builder) Cap() int

Cap returns the capacity of the builder's underlying byte slice. It is the total space allocated for the string being built and includes any bytes already written.

Returns:

  • int: the capacity of the underlying byte slice.

func (*Builder) Grow

func (b *Builder) Grow(n int)

Grow grows b's capacity, if necessary, to guarantee space for another n bytes. After Grow(n), at least n bytes can be written to b without another allocation. If n is negative, Grow panics.

Parameters:

  • n: the number of bytes to grow.

func (*Builder) Len

func (b *Builder) Len() int

Len returns the number of accumulated bytes; b.Len() == len(b.String()).

Returns:

  • int: the number of accumulated bytes.

func (*Builder) Reset

func (b *Builder) Reset()

Reset resets the Builder to be empty.

func (*Builder) String

func (b *Builder) String() string

String returns the accumulated string.

Returns:

  • string: the accumulated string.

func (*Builder) Write

func (b *Builder) Write(p []byte) (int, error)

Write appends the contents of p to b's buffer. Write always returns len(p), nil.

Parameters:

  • p: the bytes to write.

Returns:

  • int: the number of bytes written.
  • error: always nil.

func (*Builder) WriteBool

func (b *Builder) WriteBool(bl bool) error

WriteBool appends "true" or "false".

Parameters:

  • bl: the boolean to write.

Returns:

  • error: any error encountered.

func (*Builder) WriteByte

func (b *Builder) WriteByte(c byte) error

WriteByte appends the byte c to b's buffer. The returned error is always nil.

Parameters:

  • c: the byte to write.

Returns:

  • error: always nil.

func (*Builder) WriteFloat

func (b *Builder) WriteFloat(f float64, fmt byte, prec, bitSize int) error

WriteFloat appends the string form of the floating-point number f.

Parameters:

  • f: the float to write.
  • fmt: the format.
  • prec: the precision.
  • bitSize: the bit size.

Returns:

  • error: any error encountered.

func (*Builder) WriteInt

func (b *Builder) WriteInt(i int64, base int) error

WriteInt appends the string form of the integer i.

Parameters:

  • i: the integer to write.
  • base: the base to use.

Returns:

  • error: any error encountered.

func (*Builder) WriteQuote

func (b *Builder) WriteQuote(s string) error

WriteQuote appends a double-quoted Go string literal representing s.

Parameters:

  • s: the string to quote.

Returns:

  • error: any error encountered.

func (*Builder) WriteQuoteRune

func (b *Builder) WriteQuoteRune(r rune) error

WriteQuoteRune appends a single-quoted Go character literal representing the rune.

Parameters:

  • r: the rune to quote.

Returns:

  • error: any error encountered.

func (*Builder) WriteQuoteRuneToASCII

func (b *Builder) WriteQuoteRuneToASCII(r rune) error

WriteQuoteRuneToASCII appends a single-quoted Go character literal representing the rune.

Parameters:

  • r: the rune to quote.

Returns:

  • error: any error encountered.

func (*Builder) WriteQuoteRuneToGraphic

func (b *Builder) WriteQuoteRuneToGraphic(r rune) error

WriteQuoteRuneToGraphic appends a single-quoted Go character literal representing the rune.

Parameters:

  • r: the rune to quote.

Returns:

  • error: any error encountered.

func (*Builder) WriteQuoteToASCII

func (b *Builder) WriteQuoteToASCII(s string) error

WriteQuoteToASCII appends a double-quoted Go string literal representing s.

Parameters:

  • s: the string to quote.

Returns:

  • error: any error encountered.

func (*Builder) WriteQuoteToGraphic

func (b *Builder) WriteQuoteToGraphic(s string) error

WriteQuoteToGraphic appends a double-quoted Go string literal representing s.

Parameters:

  • s: the string to quote.

Returns:

  • error: any error encountered.

func (*Builder) WriteRune

func (b *Builder) WriteRune(r rune) (int, error)

WriteRune appends the UTF-8 encoding of Unicode code point r to b's buffer. It returns the length of r and a nil error.

Parameters:

  • r: the rune to write.

Returns:

  • int: the length of the rune.
  • error: always nil.

func (*Builder) WriteString

func (b *Builder) WriteString(s string) (int, error)

WriteString appends the contents of s to b's buffer. It returns the length of s and a nil error.

Parameters:

  • s: the string to write.

Returns:

  • int: the length of the string.
  • error: always nil.

func (*Builder) WriteUint

func (b *Builder) WriteUint(i uint64, base int) error

WriteUint appends the string form of the unsigned integer i.

Parameters:

  • i: the unsigned integer to write.
  • base: the base to use.

Returns:

  • error: any error encountered.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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