1234567891011121314151617181920212223242526272829 |
- package main
- import (
- "fmt"
- "red-green.com/autostruct"
- )
- func main() {
- // This example will load a json file in & produce a go file with needed structures out
- var a autostruct.AutoStruct
- var err error
- err = a.Init("simple", "main", "Simple") // This will make a simple.go file
- if err != nil {
- fmt.Println(err)
- } else {
- defer a.Close()
- a.PlacePackageName()
- a.Newline()
- a.Comment("simple.json") // the file we will be loading in is 'simple.json'
- var structCount int
- structCount, err = a.LoadJson("simple", "")
- if err != nil {
- fmt.Println(err)
- } else {
- fmt.Printf("%d Structures created\n", structCount)
- }
- }
- }
|