Compare commits

...

1 Commits

Author SHA1 Message Date
1ff96038c4 update readme 2025-04-19 12:33:53 -05:00

View File

@ -110,6 +110,54 @@ firstIP, err := cfg.GetString("allowed_ips.0")
username, err := cfg.GetString("database.credentials.username")
```
## Writing Data
Fin supports writing data back to its format, allowing you to create or modify data at runtime:
```go
package main
import (
"os"
"git.sharkk.net/Sharkk/Fin"
)
func main() {
// Create new data structure
data := fin.NewData()
// Set values
data.GetData()["server"] = map[string]any{
"host": "localhost",
"port": 8080,
}
data.GetData()["debug"] = true
data.GetData()["allowed_ips"] = []any{
"192.168.1.1",
"10.0.0.1",
}
// Write to file
file, err := os.Create("config.conf")
if err != nil {
panic(err)
}
defer file.Close()
// Use the Write method
err = data.Write(file)
if err != nil {
panic(err)
}
// Or use the standalone Save function
err = fin.Save(file, data)
if err != nil {
panic(err)
}
}
```
## Performance
Fin goes blow-for-blow against Go's standard JSON library, and performs incredibly versus