goSources

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func AstWalk

func AstWalk(filename string)

func DisplayDecl

func DisplayDecl(title string, decl []Declaration, value string, pDesc ...bool)

displayDecl: Simply display retrieved content for debug purpose

func GoFormatBytes

func GoFormatBytes(inBytes []byte) (outByte []byte, err error)

GoFormatBytes: Format bytes like gofmt function.

func GoFormatFile

func GoFormatFile(filename string) (err error)

GoFormatFile: Format file like gofmt function.

Types

type Declaration

type Declaration struct {
	From      string
	Params    []Declaration
	Name      string
	Value     string
	Type      string // string, int, bool ...
	Kind      string // var, const, :=, =
	Content   []byte
	OfstStart int
	OfstEnd   int
	LineStart int
	LineEnd   int
	// Prarams secific
	TypeAst     string
	Desc        string
	NameFromSrc string
}

type GoDeclarations

type GoDeclarations struct {
	Filename string

	PackageName    string
	DataPresent    bool
	Functions      []storeDecl
	FunctNoComment []storeDecl
	FullFunc       []storeDecl
	Types          []storeDecl
	TypesNoComment []storeDecl
	Imports        []storeDecl
	FoundRows      []storeDecl
	Var            []storeDecl
	// contains filtered or unexported fields
}

func (*GoDeclarations) GoSourceGetInfos

func (d *GoDeclarations) GoSourceGetInfos(filename string, funcName ...string) (err error)

getPackageName: retrieve package name of Go source file

func (*GoDeclarations) GoSourceGetLines

func (d *GoDeclarations) GoSourceGetLines(filename string, wholeWord bool, terms ...string) (exist bool, err error)

getPackageName: retrieve package name of Go source file

type GoSourceFileStructure

type GoSourceFileStructure struct {
	Filename           string
	WriteAstToFilename string // Leave blank, do not save the AST file. To do before initialisation if needed.
	Package            string
	Imports            []Declaration
	Func               []Declaration
	CallExpr           []Declaration
	Comments           []Declaration
	Struct             []Declaration
	Var                []Declaration
	UnImplemented      []Declaration
	Unknown            []Declaration
	Eol                string        // End of line type of the input file
	AstOut             *bytes.Buffer // AST representation of the input file

	// Used to get a new empty structure when the library is not directly in the "import" section
	// but declared as a new type in the source of the end user (that's how I use it in most cases).
	EmptyDeclStruct      Declaration
	EmptySliceDeclStruct []Declaration
	// contains filtered or unexported fields
}

func (*GoSourceFileStructure) GetFuncByName

func (gsfs *GoSourceFileStructure) GetFuncByName(dName string) (decl *Declaration)

GetFuncDeclByName: get function declaration by name

func (*GoSourceFileStructure) GetFuncPos

func (gsfs *GoSourceFileStructure) GetFuncPos(fName string) (lStart, lEnd int)

GetPosFunc: get line start and line end of the specified function

func (*GoSourceFileStructure) GetStructByName

func (gsfs *GoSourceFileStructure) GetStructByName(dName string) (decl *Declaration)

GetFuncDeclByName: get structure declaration by name

func (*GoSourceFileStructure) GetVarByName

func (gsfs *GoSourceFileStructure) GetVarByName(dName string, kind ...string) (decl *Declaration)

GetFuncDeclByName: get variable declaration by name "kind" means: "var" ,"const" ,":=" ,"="

func (*GoSourceFileStructure) GoSourceFileStructureSetup

func (gsfs *GoSourceFileStructure) GoSourceFileStructureSetup(filename string, zero ...bool) (err error)

GoSourceFileStructureSetup: setup and retieve information for designed file. Notice: the lines numbers and offsets start at 0. Set "zero" at false to start at 1.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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