Compare commits
No commits in common. "master" and "v1.1.0" have entirely different histories.
48
README.md
48
README.md
|
@ -110,54 +110,6 @@ firstIP, err := cfg.GetString("allowed_ips.0")
|
||||||
username, err := cfg.GetString("database.credentials.username")
|
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
|
## Performance
|
||||||
|
|
||||||
Fin goes blow-for-blow against Go's standard JSON library, and performs incredibly versus
|
Fin goes blow-for-blow against Go's standard JSON library, and performs incredibly versus
|
||||||
|
|
Loading…
Reference in New Issue
Block a user