| Age | Commit message (Collapse) | Author |
|
Go 1.22 now support for-range on numeric value.
|
|
Previously, appending a new variable into section always create an empty
line before after the variable.
For example, given the following section,
[a]
k = v
[c]
append "k2=v2" to section "a" will result
[a]
k = v
k2=v
[c]
This changes fix this by appending variable only after non-empty lines,
which result to
[a]
k = v
k2= v
[c]
While at it, add empty space before variable value.
|
|
Previously, if INI file contains multi line variables, for example
key = a \
b
The Get and saved value is "a \tb", where it should be "a b" for Get and
"a \\\n\t\b" again when saved.
This changes require refactoring how the variable's value is parsed and
stored.
A variable value is parsed and stored from character after "=" until new
line or comment as raw value, and the real value is derived by trimming
white spaces, handle escaped character and double quotes.
|
|
Previously, the comment is parsed and stored separately.
This changes make the comment as part of format.
|
|
|
|
Changes,
* reader: from 184 to 168 bytes (-16 bytes)
* Section: from 104 to 88 bytes (-16 bytes)
* structField: from 120 to 112 bytes (-8 bytes)
* variable: from 120 to 104 bytes (-16 bytes)
|
|
|
|
For example, if the section has the following key "x:1" and "y:3", adding
another key "x:2" should add after the first "x" key, which result
in: "x:1", "x:2", "y:3".
|
|
In Git specification, an empty variable is equal to boolean true.
This cause inconsistency between empty string and boolean true.
This changes make the empty value become an empty string instead of
boolean true.
|
|
Previous behaviour of Set() method will return false if the section
or subsection of key to be set not found on database.
This commit change the behaviour of Set(). If no section or subsection
found on database, the new section with key-value will be created.
If no key found, the new key-value will be added to the specific section.
|
|
|
|
The following methods are added to support templating using this package,
* Subs(): a method that return all non-empty subsections
* Val(): a method that return the last variable's value using key's path
as combination of section-name ":" sub-section-name ":" key.
* Vals(): a method that return all variable values as slice of string
This changes cause the section type to be exported back, again.
|
|
This is the fifth part of refactoring ini package.
Some of the changes,
* add() now will append the new variable if the same already exist but
the value is different.
* remove unused getFirstIndex() method
* add method getVariable() that return the last variable in the section
by key
* set() method will not add or append new variable if key is not exist,
instead it will return false.
* unset() method will remove the last variable on section, even if key
is duplicate.
|
|
This is the second part of refactoring to provide clean and readable
code.
|
|
This is the first part to refactoring ini package to provide a clean
and simple API.
|
|
Pruning the INI variables means removing the empty lines, the comments,
and merge section and subsection that have the same name into one
group.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Also,
* Export variable type
* Export section type
* Set print format if variable's format is empty
|
|
Previous benchmark result (22dcd07 Move buffer to reader),
BenchmarkParse-2 500 19534400 ns/op 4656335 B/op 81163 allocs/op
New benchmark result,
BenchmarkParse-2 20000 71120 ns/op 35368 B/op 549 allocs/op
|
|
|
|
Package ini implement reading and writing INI configuration as defined by
Git configuration file syntax [1].
[1] https://git-scm.com/docs/git-config#_configuration_file
|