MapTo cannot parse values as uint8
Describe the bug Parsing the following:
[mysection]
mykey=90
When using MapTo results in:
set field "mykey": unsupported type "uint8"
If the type is uint8:
type MySection struct {
MeyKey uint8 `json:"mykey" ini:"mykey"`
}
To Reproduce
Just load the config and use MapTo:
cfg, _ := ini.Load([]byte(`
[mysection]
mykey=90
`))
mySec := &MySection{}
err := cfg.Section("mysection").MapTo(mySec)
Expected behavior
MapTo should be able to parse values as uint8.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here, or any suggestion to fix the problem.
https://github.com/go-ini/ini/blob/5e97220809ffaa826f787728501264e9114cb834/struct.go#L211-L212
Here's where the problem might lie If you can, I suggest you switch to uint16 or a larger uint :smile:
https://github.com/go-ini/ini/blob/5e97220809ffaa826f787728501264e9114cb834/struct.go#L211-L212
Here's where the problem might lie If you can, I suggest you switch to uint16 or a larger uint 😄
That's what I did. Does the lib parse byte arrays? I wonder why that comment is there.
That's what I did. Does the lib parse byte arrays? I wonder why that comment is there.
My guess :disappointed_relieved:
All values loaded in the ini are considered to be strings, if by default 1 string character is a byte, if a non-ASCII character is encountered it will not be parsed to a byte or will be lost
// String of length 1
"a" = [97] index 0 = 97 // Englische
"α" = [206, 177] index 0 = 206 or 0? // Greek
"啊" = [229, 149, 138] index 0 = 229 or 0? // Chinese