mirror of
https://github.com/beego/bee.git
synced 2024-11-14 22:10:55 +00:00
40 lines
490 B
Go
40 lines
490 B
Go
|
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:
|
||
|
// {
|
||
|
// }
|
||
|
}
|