github.com/bingoohuang/gg@v0.0.0-20240325092523-45da7dee9335/pkg/strcase/README.md (about)

     1  # strcase
     2  
     3  forked from https://github.com/iancoleman/strcase
     4  
     5  strcase is a go package for converting string to various cases (e.g. [snake case](https://en.wikipedia.org/wiki/Snake_case) or [camel case](https://en.wikipedia.org/wiki/CamelCase)) to see the full conversion table below.
     6  
     7  ## Example
     8  
     9  
    10  | s                      | Function                   | Result                   |
    11  |------------------------|----------------------------|--------------------------|
    12  | `AnyKind of string v5` | `ToSnake(s)`               | `any_kind_of_string_v5`  |
    13  | `AnyKind of string v5` | `ToSnakeUpper(s)`          | `ANY_KIND_OF_STRING_V5`  |
    14  | `AnyKind of string v5` | `ToKebab(s)`               | `any-kind-of-string-v5`  |
    15  | `AnyKind of string v5` | `ToKebabUpper(s)`          | `ANY-KIND-OF-STRING5-V5` |
    16  | `AnyKind of string v5` | `ToDelimited(s, '.')`      | `any.kind.of.string.v5`  |
    17  | `AnyKind of string v5` | `ToDelimitedUpper(s, '.')` | `ANY.KIND.OF.STRING.V5`  |
    18  | `AnyKind of string v5` | `ToCamel(s)`               | `AnyKindOfStringV5`      |
    19  | `mySQL`                | `ToCamel(s)`               | `MySql`                  |
    20  | `AnyKind of string v5` | `ToCamelLower(s)`          | `anyKindOfStringV5`      |
    21  | `ID`                   | `ToCamelLower(s)`          | `id`                     |
    22  | `SQLMap`               | `ToCamelLower(s)`          | `sqlMap`                 |
    23  | `TestCase`             | `ToCamelLower(s)`          | `fooBar`                 |
    24  | `foo-bar`              | `ToCamelLower(s)`          | `fooBar`                 |
    25  | `foo_bar`              | `ToCamelLower(s)`          | `fooBar`                 |
    26  
    27  
    28  case conversion types:
    29  
    30  - Camel Case (e.g. CamelCase)
    31  - Lower Camel Case (e.g. lowerCamelCase)
    32  - Snake Case (e.g. snake_case)
    33  - Screaming Snake Case (e.g. SCREAMING_SNAKE_CASE)
    34  - Kebab Case (e.g. kebab-case)
    35  - Screaming Kebab Case(e.g. SCREAMING-KEBAB-CASE)
    36  - Dot Notation Case (e.g. dot.notation.case)
    37  - Screaming Dot Notation Case (e.g. DOT.NOTATION.CASE)
    38  - Title Case (e.g. Title Case)
    39  - Other delimiters
    40  
    41  ## resources
    42  
    43  1. [caps a case conversion library for Go](https://github.com/chanced/caps)