ast_test.go 642 B

1234567891011121314151617181920212223242526272829303132
  1. package ast
  2. import (
  3. "github.com/flipped-aurora/gin-vue-admin/server/global"
  4. "go/ast"
  5. "go/parser"
  6. "go/printer"
  7. "go/token"
  8. "os"
  9. "path/filepath"
  10. "testing"
  11. )
  12. func TestAst(t *testing.T) {
  13. filename := filepath.Join(global.GVA_CONFIG.AutoCode.Root, global.GVA_CONFIG.AutoCode.Server, "plugin", "gva", "plugin.go")
  14. fileSet := token.NewFileSet()
  15. file, err := parser.ParseFile(fileSet, filename, nil, parser.ParseComments)
  16. if err != nil {
  17. t.Error(err)
  18. return
  19. }
  20. err = ast.Print(fileSet, file)
  21. if err != nil {
  22. t.Error(err)
  23. return
  24. }
  25. err = printer.Fprint(os.Stdout, token.NewFileSet(), file)
  26. if err != nil {
  27. panic(err)
  28. }
  29. }