1
0
mirror of https://github.com/beego/bee.git synced 2024-11-14 22:10:55 +00:00
bee/parser/parser_test.go

40 lines
490 B
Go
Raw Normal View History

2021-05-22 14:14:59 +00:00
package beeParser
import (
"fmt"
"log"
)
func ExampleConfigGenerator() {
const src = `
package p
import "http"
type StructB struct {
Field1 string
}
type StructA struct {
Field1 string
Field2 StructB
Field3 []string
Field4 map[string]string
Field5 http.SameSite
}
`
cg, err := NewConfigGenerator("./sample.go", src, "StructA")
if err != nil {
log.Fatal(err)
}
b, err := cg.ToJSON()
if err != nil {
log.Fatal(err)
}
fmt.Println(string(b))
// Output:
// {
// }
}