go-ini
is a Go package tailored for manipulation, reading, and writing of INI files. This package is specifically designed to be compliant with Magic Software's "Magic.ini" format.
- Magic Software Compliance: Adheres to the "Magic.ini" format specifications.
- Load and Parse: Efficiently reads INI files.
- Write and Update: Capable of writing updates to existing INI files or creating new ones.
- Section and Key Extraction: Extract sections and keys from INI content with ease.
- Value Translation: Translate values based on translatable sections.
To install the package, use:
go get github.com/devzolo/go-ini
package main
import (
"fmt"
"github.com/devzolo/go-ini"
)
func main() {
cfg := ini.NewMagicIni()
err := cfg.LoadIni("path/to/your/magic.ini")
if err != nil {
panic(err)
}
value := cfg.Get("SomeSection", "SomeKey")
fmt.Println(value)
}
Represents a structured format of an INI file compliant with the "Magic.ini" standards. It houses the parsed data, the currently parsed section, and the section with translatable strings.
NewMagicIni()
: Creates and returns a newMagicIni
instance.LoadIni(path string)
: Reads and parses an INI file, particularly "Magic.ini", from the specified path.LoadAdditionalIni(path string)
: Loads an additional INI file from the specified path, merging its contents with the existing data.Get(section string, key string)
: Fetches a value for a specific section and key.Translate(str string)
: Translates placeholders in the provided string using the corresponding strings from theTranslatableSection
.