goparser

package module
v0.0.0-...-5685e45 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2015 License: Apache-2.0 Imports: 3 Imported by: 1

README

goparser

A simplified parser for Golang source files.

If you want to parse the types in a Golang source file but find the bare go/ast and go/parser hard to use, this library would be useful to you.

Travis last test result on master

Gourd

Gourd wants to be a rapid development framework.

It's writer wants to have something to kickstart a RESTful JSON API project really quick. He also wants to be able to override anything in the framework easily.

Status

This is under active development.

If you have any cool idea you want to add to this framework, please send a pull request. If you find bug, please file an issue in our issue tracker.

Licence

This software is licenced under Apache Licence v2.0. For details, please read the LICENCE file in this repository.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChanDecls

func ChanDecls(decls []ast.Decl) <-chan ast.Decl

ChanDecls channel the slice of ast.Decl out for filtering

func CmtGrpToStr

func CmtGrpToStr(cg *ast.CommentGroup) (str string)

CmtGrpToStr convert comment group to string read comment group to string

func CmtToStr

func CmtToStr(cmt *ast.Comment) string

CmtToStr cmment to string

func DeclsToTypes

func DeclsToTypes(decls []ast.Decl) <-chan *TypeSpec

DeclsToTypes filter and transform decls to types

func FilterGenDecl

func FilterGenDecl(cin <-chan ast.Decl) <-chan *ast.GenDecl

FilterGenDecl filter only GetDecl out of ast.Decl

func FilterStructType

func FilterStructType(cin <-chan *ast.TypeSpec) <-chan *ast.StructType

FilterStructType filter only StructType from TypeSpec

func FilterTypeSpec

func FilterTypeSpec(cin <-chan *ast.GenDecl) <-chan *ast.TypeSpec

FilterTypeSpec filter only TypeSpec from GenDecl

Types

type FieldSpec

type FieldSpec struct {
	Name    string
	Type    string
	Tag     string
	Doc     string
	Comment string
}

FieldSpec representation of a general struct field

func (*FieldSpec) TagFields

func (s *FieldSpec) TagFields() <-chan *TagField

Tags read the Tag text into a map of string

func (*FieldSpec) Tagged

func (s *FieldSpec) Tagged(name, value string) bool

Tagged determine if the field is tagged with value as the primary value (the 1st in comma separated list)

func (*FieldSpec) TaggedExtra

func (s *FieldSpec) TaggedExtra(name, value string) bool

TaggedExtra determine if the field is tagged with given secondary values (not 1st in comma separated list)

type TagField

type TagField struct {
	Name   string
	Value  string
	Extras []string
}

TagField representats structure of a tag field

type TypeSpec

type TypeSpec struct {
	Name    string
	Type    string
	Fields  []FieldSpec
	Doc     string
	Comment string
}

TypeSpec representation of a general type spec

func ParseTypeSpec

func ParseTypeSpec(typeSpec *ast.TypeSpec) (spec TypeSpec)

ParseTypeSpec parse a type spec into TypeSpec

func (*TypeSpec) FieldsTagged

func (s *TypeSpec) FieldsTagged(name, value string) <-chan *FieldSpec

FieldsTagged return a channel that will yield all FieldSpec of field which is tagged a certain tag name and primary value

func (*TypeSpec) FieldsTaggedExtra

func (s *TypeSpec) FieldsTaggedExtra(name, value string) <-chan *FieldSpec

FieldsTagged return a channel that will yield all FieldSpec of field which is tagged a certain tag name and secondary value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL