SAN-go
SAN (pronounce /seɪn/, like sane) CLI and parser for Go.
Spec: https://astrocorp.net/san
Compatible with SAN version: v1.0.0
Installation
go get -u github.com/bloom42/san-go/...Library
package main
import (
"fmt"
"github.com/bloom42/san-go"
)
type D struct {
A string
}
type C struct {
A int64 `san:"a"`
D []D `san:"d"`
}
type S struct {
A string `san:"a"`
B []int64 `san:"b"`
C C `san:"c"`
}
func main() {
str1 := `
a = "a"
b = [1, 2]
c = { a = 1, d = [ { a = "3.3" }, { a = "xxx" } ] }
`
var s S
err := san.Unmarshal([]byte(str1), &s)
if err != nil {
panic(err)
}
fmt.Printf("%#v\n\n", s)
b, err := san.Marshal(s)
if err != nil {
panic(err)
}
fmt.Print(string(b))
}go run main.go
main.S{A:"a", B:[]int64{1, 2}, C:main.C{A:1, D:[]main.D{main.D{A:"3.3"}, main.D{A:"xxx"}}}}
a = "a"
b = [
1,
2,
]
c = {
a = 1
d = [
{
A = "3.3"
},
{
A = "xxx"
},
]
}CLI
This repo also contains a CLI helper for the SAN format. It can be installed with the following command:
$ go get -u github.com/bloom42/san-go/...Examples
Convert a [.toml, .json, .yml, .yaml] file to a .san
$ san convert ../config.yml # wil create ../config.sanAutomatically formats a SAN file
$ san fmt config.sanCheck a .san file validity
$ san validate config.san