🚀
Easy to Use
Simple API for parsing rebar.config files into structured Go objects with comprehensive helper methods.
Parse, access, and format Erlang rebar.config files with ease
package main
import (
"fmt"
"log"
"github.com/scagogogo/erlang-rebar-config-parser/pkg/parser"
)
func main() {
// Parse a rebar.config file
config, err := parser.ParseFile("path/to/rebar.config")
if err != nil {
log.Fatalf("Failed to parse config: %v", err)
}
// Get and print dependencies
deps, ok := config.GetDeps()
if ok && len(deps) > 0 {
if depsList, ok := deps[0].(parser.List); ok {
fmt.Printf("Found %d dependencies\n", len(depsList.Elements))
for _, dep := range depsList.Elements {
if tuple, ok := dep.(parser.Tuple); ok && len(tuple.Elements) >= 2 {
if atom, ok := tuple.Elements[0].(parser.Atom); ok {
fmt.Printf("- Dependency: %s\n", atom.Value)
}
}
}
}
}
// Format and print the config with nice indentation
fmt.Println("\nFormatted config:")
fmt.Println(config.Format(2))
}
go get github.com/scagogogo/erlang-rebar-config-parser
Erlang Type | Example | Go Representation |
---|---|---|
Atoms | atom_name , 'quoted-atom' | Atom{Value: "atom_name", IsQuoted: false} |
Strings | "hello world" | String{Value: "hello world"} |
Integers | 123 , -42 | Integer{Value: 123} |
Floats | 3.14 , -1.5e-3 | Float{Value: 3.14} |
Tuples | {key, value} | Tuple{Elements: []Term{...}} |
Lists | [1, 2, 3] | List{Elements: []Term{...}} |