Able to set incremental keys
zelang opened this issue · 1 comments
zelang commented
Version
1.67.0
Describe the bug
If key name is - in data source, then it would be seen as special syntax for auto-increment key name start from 1, and every section is independent on counter.
I want to add a key value to the auto increment key name.
To reproduce
package main
import (
"gopkg.in/ini.v1"
"log"
)
func main() {
cfgs, err := ini.Load([]byte(`[features]
-: Support read/write comments of keys and sections
-: Support auto-increment of key names
-: Support load multiple files to overwrite key values`))
if err != nil {
log.Fatalf("Error: %s", err.Error())
}
newkey, _ := cfgs.Section("features").NewKey("-", "dasda")
keys := cfgs.Section("features").KeyStrings()
log.Println(newkey)
log.Println(keys)
// [#1 #2 #3 -]
}
But I print the added keys and get a key value other than #4
, but -
Expected behavior
I want to get a key value like #4
, but -
Additional context
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
unknwon commented
The transformation happens at parser stage, so for now I think you would have to save the file and reload back.