Go package for parsering Fluentbit .conf
configuration file.
Read more: Fluentbit Configuration Document
- Support Section and Entry objects
- Support Commands
- Export all entries of a section into a map object (
Section.EntryMap()
).
go get -u github.com/stevedsun/go-fluentbit-conf-parser
package main
import (
"fmt"
"os"
parser "github.com/stevedsun/go-fluentbit-conf-parser"
)
func main() {
confFile, _ := os.Open("fluentbit.conf")
defer confFile.Close()
conf := parser.NewFluentBitConfParser(confFile).Parse()
for _, include := range conf.Includes {
fmt.Printf("@INCLUDE %v\n", include)
}
for key, value := range conf.Sets {
fmt.Printf("@SET %v=%v\n", key, value)
}
for _, section := range conf.Sections {
fmt.Printf("[%v]\n", section.Name)
for _, entry := range section.Entries {
fmt.Printf(" %v %v\n", entry.Key, entry.Value)
}
}
}