main.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package main
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "os"
  6. )
  7. func main() {
  8. p := Parser{DebugJSON: "_debug.json"}
  9. root, err := p.Load("Test Dummy.txt")
  10. if err != nil {
  11. fmt.Println("Parser.Load", err)
  12. return
  13. }
  14. profile := Profile{}
  15. err = profile.Parse(root)
  16. if err != nil {
  17. fmt.Println("Profile.Parse", err)
  18. return
  19. }
  20. pay, err := json.MarshalIndent(profile, "", " ")
  21. if err != nil {
  22. fmt.Println("Marshal (Profile)", err)
  23. return
  24. }
  25. err = os.WriteFile("_debug1.json", pay, 0660)
  26. if err != nil {
  27. fmt.Println("WriteFile", err)
  28. return
  29. }
  30. fmt.Println(profile.Pilot)
  31. fmt.Println(profile.Date.String())
  32. fmt.Println(profile.Location.String())
  33. fmt.Println(profile.Travel.String())
  34. /*profile.Travel.Path = append(profile.Travel.Path, "Someplace")
  35. profile.Travel.Destination = "Someplace Safe"
  36. err = profile.Update()
  37. if err != nil {
  38. fmt.Println("Profile.Update", err)
  39. return
  40. }*/
  41. pay, err = json.MarshalIndent(root, "", " ")
  42. if err != nil {
  43. fmt.Println("Marshal (Root)", err)
  44. return
  45. }
  46. err = os.WriteFile("_debug2.json", pay, 0660)
  47. if err != nil {
  48. fmt.Println("WriteFile", err)
  49. return
  50. }
  51. }