main2.go 645 B

1234567891011121314151617181920212223242526272829
  1. package main
  2. import (
  3. "fmt"
  4. "red-green.com/autostruct"
  5. )
  6. func main() {
  7. // This example will load a json file in & produce a go file with needed structures out
  8. var a autostruct.AutoStruct
  9. var err error
  10. err = a.Init("simple", "main", "Simple") // This will make a simple.go file
  11. if err != nil {
  12. fmt.Println(err)
  13. } else {
  14. defer a.Close()
  15. a.PlacePackageName()
  16. a.Newline()
  17. a.Comment("simple.json") // the file we will be loading in is 'simple.json'
  18. var structCount int
  19. structCount, err = a.LoadJson("simple", "")
  20. if err != nil {
  21. fmt.Println(err)
  22. } else {
  23. fmt.Printf("%d Structures created\n", structCount)
  24. }
  25. }
  26. }