aboutsummaryrefslogtreecommitdiff
path: root/lib/ini/section.go
AgeCommit message (Collapse)Author
2025-01-23all: use for-range with numericShulhan
Go 1.22 now support for-range on numeric value.
2023-11-12lib/ini: append variable into section before any empty linesShulhan
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.
2022-07-27lib/ini: fix parsing and saving multi line variablesShulhan
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.
2022-07-26lib/ini: parse comment as part of formatShulhan
Previously, the comment is parsed and stored separately. This changes make the comment as part of format.
2022-05-09all: reformat all codes using gofmt 1.19 (the Go tip)Shulhan
2022-02-06lib/ini: realign all structsShulhan
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)
2020-08-23ini: ignore the last empty line on unsetAllShulhan
2020-05-16ini: make the add method append the variable after existing same keyShulhan
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".
2020-05-16ini: fix inconsistencies between empty string and boolean trueShulhan
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.
2019-06-18ini: create new section or variable if not exist on SetShulhan
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.
2019-06-07ini: add method to get section object by section and/or subsection nameShulhan
2019-05-26ini: add methods to support templatingShulhan
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.
2019-05-26ini: refactoring section methodsShulhan
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.
2019-05-25ini: rename varModeXXX to lineModeXXXShulhan
This is the second part of refactoring to provide clean and readable code.
2019-05-25ini: unexport Variable and SectionShulhan
This is the first part to refactoring ini package to provide a clean and simple API.
2019-05-25ini: add method to prune INI variablesShulhan
Pruning the INI variables means removing the empty lines, the comments, and merge section and subsection that have the same name into one group.
2019-05-25ini: cleanup, reformat, and repharase commentsShulhan
2019-05-25ini: remove unused method AddNewLineShulhan
2019-02-25ini: add method to get all variable values with the same keyShulhan
2018-08-17lib/ini: remove unused "nolint" tagShulhan
2018-08-17lib/ini: reformat and update commentsShulhan
2018-05-18section: add parameter to set default value if key not foundShulhan
2018-05-13section: add method to add newline and commentShulhan
2018-05-13variable: Export key in lowercase fieldShulhan
2018-05-13Export section's name and their lower case nameShulhan
2018-05-13Replace field type in Section and Variable from []byte to stringShulhan
2018-05-13Export variable key and valueShulhan
2018-05-13Export Section sub, line number, and variablesShulhan
2018-05-13section: add field for line numberShulhan
2018-05-13section: change type from alias to structShulhan
2018-05-12Add copyright and license informationShulhan
2018-05-11Add method to manipulate variable in SectionShulhan
Also, * Export variable type * Export section type * Set print format if variable's format is empty
2018-05-10Refactor parser using bytes.ReaderShulhan
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
2018-05-08section.pushVar: do not trim whitespaces from key and valueShulhan
2018-05-08Add library for reading and writing INI file formatShulhan
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