|
1 | 1 | # StructTags |
2 | 2 |
|
3 | | -`structtags` provides several ways of parsing struct tags. |
| 3 | +`structtags` provides straightforward ways to parse, read, or modify struct tags. |
4 | 4 |
|
5 | 5 | - Some projects need a full parsing (key, values) |
6 | 6 | - Some others only need the key and the raw value. |
7 | 7 | - Other projects need to escape the comma. |
8 | 8 | - Etc. |
9 | 9 |
|
| 10 | +Instead of rewriting the wheel for each project, I also provided a package with the plumbing: |
| 11 | +- `parser.Tag()`: extracted from `reflect.StructTag` for the base parsing. |
| 12 | +- `parser.Value()`: to parse the value (support optional comma escaping). |
| 13 | + |
10 | 14 | This is the first version of the module, and I want to extend it based on feedback so that the API can evolve and break. |
11 | 15 |
|
12 | 16 | ## Usage |
@@ -114,6 +118,8 @@ Options: |
114 | 118 |
|
115 | 119 | ### `structtags.ParseToFatih(tag, escapeComma)` |
116 | 120 |
|
| 121 | +Compatibility layer with `fatih/structtag`. |
| 122 | + |
117 | 123 | Parses a struct tag to a `*structtag.Tags`. |
118 | 124 |
|
119 | 125 | The value is split on a comma. |
@@ -190,12 +196,6 @@ type Foo struct { |
190 | 196 |
|
191 | 197 | </details> |
192 | 198 |
|
193 | | -`ldez/structtags` provides straightforward ways to parse, read, or modify struct tags, and a compatibility layer with `fatih/structtag` if you need it. |
194 | | - |
195 | | -Instead of rewriting the wheel for each project, I also provided a package with the plumbing: |
196 | | -- `parser.Tag()`: extracted from `reflect.StructTag` for the base parsing. |
197 | | -- `parser.Value()`: to parse the value (support optional comma escaping). |
198 | | - |
199 | 199 | ## Notes |
200 | 200 |
|
201 | 201 | The [struct tag specifications](https://go.dev/ref/spec#Struct_types) say that struct tags can be any string. |
|
0 commit comments