Documentation
¶
Index ¶
- func CleanPrefix(ident string) string
- func CleanTypeNameUpper(typeName string) string
- func DispositionFileName(contentDisposition string) string
- func EmptyString(value string) bool
- func IsPathVariable(token string) bool
- func JoinPackageName(ident string) string
- func LeadingSlash(value string) string
- func NoImport(ident string) string
- func NoPackage(ident string) string
- func NoPointer(ident string) string
- func NoSlice(ident string) string
- func NotEmptyString(value string) bool
- func PathTokens(path string) []string
- func PathVariableName(pathSegment string) string
- func ResolvePath(path string, delim rune, variableFunc func(string) string) string
- func ToLowerCamel(value string) string
- func ToUpperCamel(value string) string
- func TokenizePath(path string, delim rune) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanPrefix ¶
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 ¶
CleanTypeNameUpper normalizes a raw type's name to be a single token name in upper camel case.
func DispositionFileName ¶
DispositionFileName extracts the "filename" from an HTTP Content-Disposition header value.
func EmptyString ¶
EmptyString is a predicate that returns true when the input value is "".
func IsPathVariable ¶ added in v0.1.1
IsPathVariable returns true if the given path segment value looks like it's a variable.
IsPathVariable("user") -> false IsPathVariable(":user") -> false IsPathVariable("{ID}") -> true IsPathVariable("{Group.Organization.ID}") -> true
func JoinPackageName ¶
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 ¶
LeadingSlash adds... a leading slash to the given string.
func NoImport ¶
NoImport strips off the prefix before "/" in your type identifier (e.g. "github.com/foo/bar/Baz" -> "Baz")
func NoPackage ¶
NoPackage strips of any package prefixes from an identifier (e.g. "context.Context" -> "Context")
func NoPointer ¶
NoPointer strips off any "*" prefix your type identifier might have (e.g. "*Foo" -> "Foo")
func NoSlice ¶
NoSlice takes a string like "[]Foo" or "[456]Foo", strips off the slice/array braces, leaving you with "Foo".
func NotEmptyString ¶
NotEmptyString is a predicate that returns true when the input value is anything but "".
func PathTokens ¶
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 PathVariableName ¶ added in v0.1.1
PathVariableName returns the raw variable name of the path variable if it actually is a variable (e.g. "{Foo.ID"}" becomes "Foo.ID). If it's not a path variable, then this return "" (e.g "User" -> "").
func ResolvePath ¶ added in v0.1.3
ResolvePath accepts a path that potentially includes path variables (e.g. "{ID}) and uses the 'variableFunc' to replace those tokens in the path w/ some runtime value.
ResolvePath("foo/BAR", '/', strings.ToLower) --> "foo/BAR") ResolvePath("foo/{BAR}", '/', strings.ToLower) --> "foo/bar")
func ToLowerCamel ¶
ToLowerCamel converts the string to lower camel-cased.
func ToUpperCamel ¶
ToUpperCamel converts the string to upper camel-cased.
func TokenizePath ¶ added in v0.1.1
TokenizePath follows our standard segment/variable naming conventions and splits a path such as "foo/{bar/baz}/goo" or "foo.{bar.baz}.goo" into the slice ["foo", "{bar.baz}", "goo"].
Types ¶
This section is empty.