You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,6 +118,19 @@ func main() {
118
118
}
119
119
```
120
120
121
+
### Ints
122
+
123
+
It is also possible to set struct fields as `int` to get the string automatically converted.
124
+
125
+
```go
126
+
// Matches "12 wombats", "1 wombat" and store the number as int
127
+
typeWisdomstruct {
128
+
Numberint`^\d+`
129
+
_ string`\s+`
130
+
Animalstring`\w+`
131
+
}
132
+
```
133
+
121
134
### Optional fields
122
135
123
136
When nesting one struct within another, you can make the nested struct optional by marking it with `?`. The following example parses floating point numbers with optional sign and exponent:
0 commit comments