naming

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanPrefix

func CleanPrefix(ident string) string

CleanPrefix strips the "command-line-arguments." prefix that the Go 'packages' package prepends to type identifier for types defined in the source file we're parsing.

func CleanTypeNameUpper

func CleanTypeNameUpper(typeName string) string

func EmptyString

func EmptyString(value string) bool

EmptyString is a predicate that returns true when the input value is "".

func JoinPackageName

func JoinPackageName(ident string) string

JoinPackageName converts a package-qualified type such as "fmt.Stringer" into a single "safe" identifier such as "fmtStringer". This is useful when converting types to languages with different naming semantics.

func LeadingSlash

func LeadingSlash(value string) string

LeadingSlash adds... a leading slash to the given string.

func NoImport

func NoImport(ident string) string

NoImport strips off the prefix before "/" in your type identifier (e.g. "github.com/foo/bar/Baz" -> "Baz")

func NoPackage

func NoPackage(ident string) string

NoPackage strips of any package prefixes from an identifier (e.g. "context.Context" -> "Context")

func NoPointer

func NoPointer(ident string) string

NoPointer strips off any "*" prefix your type identifier might have (e.g. "*Foo" -> "Foo")

func NoSlice

func NoSlice(ident string) string

NoSlice takes a string like "[]Foo" or "[456]Foo", strips off the slice/array braces, leaving you with "Foo".

func NotEmptyString

func NotEmptyString(value string) bool

NotEmptyString is a predicate that returns true when the input value is anything but "".

func PathTokens

func PathTokens(path string) []string

PathTokens accepts a path string like "foo/bar/baz" and returns a slice of the individual path segment tokens such as ["foo", "bar", "baz"]. This will ignore leading/trailing slashes in your path so that you don't get leading/trailing "" tokens in your slice. This does not, however, clean up empty tokens caused by "//" somewhere in your path.

func ToLowerCamel

func ToLowerCamel(value string) string

ToLowerCamel converts the string to lower camel-cased.

func ToUpperCamel

func ToUpperCamel(value string) string

ToUpperCamel converts the string to upper camel-cased.

Types

This section is empty.

Jump to

Keyboard shortcuts

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