goparser

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyFile = errors.New("file is empty")

ErrEmptyFile represents an empty file error.

Functions

This section is empty.

Types

type Enum

type Enum struct {
	Name   string
	Type   string
	Values []EnumValue
}

Enum represents an enumerated type in go file

type EnumValue

type EnumValue struct {
	Name  string
	Value any
}

type Function added in v0.2.0

type Function struct {
	Name       string
	SourceCode []byte
	Receiver   *Receiver
}
type Header struct {
	Comments []string
	Package  string
}

type Parser

type Parser struct{}

Parser can parse Go files.

func NewParser

func NewParser() *Parser

func (*Parser) Parse

func (p *Parser) Parse(srcPath string, files []string) (*Result, error)

Parse parses a given Go file at srcPath, along with all files that share the same package, into a domain model for enum code genration.

type Receiver added in v0.2.0

type Receiver struct {
	Name    string
	Type    string
	Pointer bool
}

type Result

type Result struct {
	// Source code of a Go file
	SourceCode []byte

	// The package name of a Go file.
	Header *Header

	// All the enums in a Go file.
	Enums []Enum

	// All the functions and methods in a Go file.
	Funcs []Function

	// All the variables in a Go file.
	Vars []Variable
}

Result representats a parsed Go file.

type Variable added in v0.2.0

type Variable struct {
	Name       string
	SourceCode []byte
}

Jump to

Keyboard shortcuts

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