parse

package
v0.0.0-...-a007d9a Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2015 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package parse contains simple go parser code to be used to generate code from interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindType

func FindType(f *ast.File, inputType string) *ast.TypeSpec

FindType finds a file level type declaration and returns it if found.

func FormatSource

func FormatSource(buf []byte) ([]byte, error)

FormatSource runs the equivalent of gofmt on the buffer and returns the formatted version.

If the code is not valid go syntax, prefix the buffer with a comment about this issue and include the buffer unformatted.

Types

type Arg

type Arg struct {
	Name string
	Pkg  string
	Type string
}

Arg is one parameter or return value.

func (*Arg) FullType

func (a *Arg) FullType(curPkg string) string

type Args

type Args []Arg

func (Args) Flat

func (a Args) Flat(curPkg string) string

func (Args) Names

func (a Args) Names() string

type Method

type Method struct {
	Name    string
	Params  []Arg
	Results []Arg
}

Method is a simplification of ast.FuncType using only strings.

func EnumInterface

func EnumInterface(pkgName string, t *ast.TypeSpec) ([]Method, error)

EnumInterface enumerates all the methods of an interface.

Useful to generate code from an interface.

Jump to

Keyboard shortcuts

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