Categorygithub.com/curoky/go-thrift-parser
module
0.9.1
Repository: https://github.com/curoky/go-thrift-parser.git
Documentation: pkg.go.dev

# README

Go thrift parser

unittest GitHub license Go Report Card GitHub release (latest SemVer) GitHub go.mod Go version GoDoc

go-thrift-parser is a Go package which parses a thrift file.

Getting started

import package

import (
  "fmt"

  "github.com/curoky/go-thrift-parser/parser"
  "github.com/curoky/go-thrift-parser/parser/ast"
)

parse thrift file

p := parser.CreateParser(false, []string{"."})
err := p.RecursiveParse("types.thrift")
if err != nil {
  panic(err)
}

visit ast

doc := p.Thrift.Documents["types.thrift"]
for _, body := range doc.Body {
  switch v := body.([]interface{})[0].(type) {
  case *ast.Include:
    fmt.Printf("include: %s\n", v.Name)
  case *ast.Type:
    fmt.Printf("type: %s\n", v.Name)
  case *ast.Service:
    fmt.Printf("service: %s\n", v.Name)
  }
}

result

type: StrType
type: EnumType
type: UnionType
type: StructType
type: OutterStructType

License

See LICENSE

# Packages

No description provided by the author
No description provided by the author
No description provided by the author