https://github.com/devzolo/go-ini
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.
https://github.com/devzolo/go-ini
golang ini lib magic-software magicini
Last synced: 9 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/devzolo/go-ini
- Owner: devzolo
- License: mit
- Created: 2021-12-27T06:51:01.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-10-18T04:13:55.000Z (over 2 years ago)
- Last Synced: 2025-07-20T07:05:56.961Z (9 months ago)
- Topics: golang, ini, lib, magic-software, magicini
- Language: Go
- Homepage: https://pkg.go.dev/github.com/devzolo/go-ini
- Size: 1.37 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-ini 🚀
`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](https://www.magicsoftware.com/) "Magic.ini" format.
[](https://github.com/devzolo/go-ini/actions?query=workflow%3ATest)
[](https://pkg.go.dev/github.com/devzolo/go-ini)
## 💡 Features
- **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.
## 🛠Usage
### 🔧 Installation
To install the package, use:
```bash
go get github.com/devzolo/go-ini
```
### Basic Usage
```go
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)
}
```
## 📚 Documentation
### 📄 `MagicIni` Structure
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.
### 🛠Primary Methods
- `NewMagicIni()`: Creates and returns a new `MagicIni` 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 the `TranslatableSection`.