astx

package module
v0.0.0-...-9a7c6d1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2015 License: MIT Imports: 7 Imported by: 2

README

package astx

Parse import specs and struct type definitions from Go files with ease.

Docs: https://godoc.org/github.com/wdamron/astx

Sourcegraph: https://sourcegraph.com/github.com/wdamron/astx

Note: Sourcegraph seems to be having issues building this package, but it does indeed build

Documentation

Index

Constants

View Source
const (
	// Parse imports within files
	OptParseImports = 1
	// Parse structs within files
	OptParseStructs = 2
)

Variables

This section is empty.

Functions

func ParseDir

func ParseDir(path string) (map[string]Package, error)

ParseDir parses all packages at path. All options will be set to their default values.

func ParseDirOptions

func ParseDirOptions(path string, options int) (map[string]Package, error)

ParseDirOptions parses all packages within path with options.

Types

type File

type File struct {
	Package string
	Path    string
	AbsPath string
	Imports []Import
	Structs []Struct
}

File represents a parsed Go source file

func ParseFile

func ParseFile(path string) (*File, error)

ParseFile parses the file at path. All options will be set to their default values.

func ParseFileOptions

func ParseFileOptions(path string, options int) (*File, error)

ParseFileOptions parses the file at path with options.

func ParseSource

func ParseSource(src interface{}) (*File, error)

ParseSource parses src. src may be of type a string, []byte, or io.Reader. All options will be set to their default values.

func ParseSourceOptions

func ParseSourceOptions(src interface{}, options int) (*File, error)

ParseSourceOptions parses src with options. src may be of type a string, []byte, or io.Reader.

type Import

type Import struct {
	Name     string
	Path     string
	Doc      []string
	Comments []string
}

Import represents an import spec parsed from a Go source file

type Package

type Package struct {
	Name  string
	Files []File
}

Package represents a parsed Go package

type Struct

type Struct struct {
	Name     string
	Comments []string
	Fields   []StructField
}

Struct represents a struct type definition parsed from a Go source file

type StructField

type StructField struct {
	Name     string
	Type     string
	Doc      []string
	Comments []string
	Tag      reflect.StructTag
	RawTag   string
	// A field definition may contain an embedded struct type definition
	StructType *Struct
}

StructField represents a field definition, within a struct type definition, parsed from a Go source file

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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