Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToCamelCase ¶
ToCamelCase : Converts the string s to camel case. The string s must start with a letter and contain only letters, numbers, and the characters '_', '-', and '.'. The first letter of the string s is converted to lowercase. If the string s is empty or does not start with a letter, the function returns an empty string. If the string s contains characters other than letters, numbers, '_', '-', and '.', the function returns an empty string. The function returns the converted string. For example: ToCamelCase("foo-bar") returns "fooBar". ToCamelCase("foo_bar") returns "fooBar". ToCamelCase("foo.bar") returns "fooBar". ToCamelCase("foo-bar-") returns "". ToCamelCase("foo-bar-1") returns "". ToCamelCase("1foo-bar") returns "". ToCamelCase("foobar") returns "foobar". ToCamelCase("fooBar") returns "fooBar".
func ToPascalCase ¶
ToPascalCase : Converts the string s to pascal case. The string s must start with a letter and contain only letters, numbers, and the characters '_', '-', and '.'. The first letter of the string s is converted to uppercase. If the string s is empty or does not start with a letter, the function returns an empty string. If the string s contains characters other than letters, numbers, '_', '-', and '.', the function returns an empty string. The function returns the converted string. For example: ToPascalCase("foo-bar") returns "FooBar". ToPascalCase("foo_bar") returns "FooBar". ToPascalCase("foo.bar") returns "FooBar". ToPascalCase("foo-bar-") returns "". ToPascalCase("foo-bar-1") returns "". ToPascalCase("1foo-bar") returns "". ToPascalCase("foobar") returns "Foobar". ToPascalCase("fooBar") returns "Foobar". ToPascalCase("fooBar1") returns "Foobar1". ToPascalCase("FooBar") returns "FooBar". ToPascalCase("foo_2-bar") returns "Foo2Bar".
func ToSnakeCase ¶
ToSnakeCase : Converts the string s to snake case. The string s must start with a letter and contain only letters, numbers, and the characters '_', '-', and '.'. The first letter of the string s is converted to lowercase. If the string s is empty or does not start with a letter, the function returns an empty string. If the string s contains characters other than letters, numbers, '_', '-', and '.', the function returns an empty string. The function returns the converted string. For example: ToSnakeCase("foo-bar") returns "foo_bar". ToSnakeCase("foo_bar") returns "foo_bar". ToSnakeCase("foo.bar") returns "foo_bar". ToSnakeCase("foo-bar-") returns "". ToSnakeCase("foo-bar-1") returns "foo_bar_1". ToSnakeCase("1foo-bar") returns "".
func Values ¶
Values converts a value to url.Values. The value can be a map, a struct, a pointer to a struct, or a pointer to a map. The value can also implement the Encoder interface. If the value is a map, the key must be a string and the value must be a string. If the value is a struct, the field must have a tag with the key "url".
Types ¶
type Converter ¶
type Converter struct {
// contains filtered or unexported fields
}
func NewConverter ¶
func (*Converter) Values ¶
Values converts a value to url.Values. The value can be a map, a struct, a pointer to a struct, or a pointer to a map. The value can also implement the Encoder interface. If the value is a map, the key must be a string and the value must be a string. If the value is a struct, the field must have a tag with the key "url" or a custom tag type. The tag value is the name of the field in the url.Values.
type Encoder ¶
Encoder is an interface implemented by any type that wishes to encode itself into URL values in a non-standard way. The Encode method returns the encoded values.
type Name ¶
type Name string
func (Name) Convert ¶
Convert : Converts the string name to the specified case. The function returns the converted string. For example: Name("camel").Convert("hello_world") returns "helloWorld". Name("pascal").Convert("hello_world") returns "HelloWorld". Name("snake").Convert("HelloWorld") returns "hello_world". Name("").Convert("hello_world") returns "hello_world".
type Tag ¶
type Tag interface { // Get returns the tag value of the struct field. Get(field reflect.StructField) (string, bool) // ParseTag parses the tag value and returns the tag name and tag options. ParseTag(tag string) (string, TagOptions) // Skip returns the value of the tag to skip the field. Skip() string }
Tag represents the tag interface. The tag interface provides the methods to get the tag value, parse the tag, and skip the field. The tag value is the value of the tag in the struct field. The parse tag method parses the tag value and returns the tag name and tag options. The skip method returns the value of the tag to skip the field.
type TagOptions ¶
type TagOptions []string
TagOptions represents the options of a tag. The options are separated by commas.
func (TagOptions) Contains ¶
func (o TagOptions) Contains(option string) bool
Contains checks whether the tagOptions contains the specified option.