common

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Files

func Files(path string, acceptExt string) ([]string, error)

Files accepts a path and returns a slice containing the path or paths (if path is a directory). acceptExt is used to filter specific file extensions.

func FindIllegalStatements

func FindIllegalStatements(sourceFile string, sourceData []byte) (_ []int, _ []Undo, _ []Undo, rErr error)

FindIllegalStatements will search for these illegal statements: - "defer go" - "fordefer" and "fordefer go" (inside for loops) The function returns where the "go" statements are (before temporary removal) The function also returns where the "fordefer" statements are and whether they were next to a "go" statement.

func InsertImport

func InsertImport(node *ast.File, alias *string, path string)

InsertImport will add an import declaration to a file (if it doesn't exist already).

func RandSeq

func RandSeq(n int) string

RandSeq generates random identifiers

func RemoveComments

func RemoveComments(tempFile string) error

RemoveComments will remove comments found inside functions to prevent interference when tree nodes are removed or manipulated.

func Report

func Report(err error) (exitCode int)

Types

type Undo

type Undo struct {
	UndoType UndoType
	Pos      int // Optional
}

Undo stores information about how to transform the converted code back to its original form. The Pos refers to the order of the identifier we are searching for in the transformed code.

type UndoType

type UndoType int
const (
	DeferGo    UndoType = 0
	Fordefer   UndoType = 1
	FordeferGo UndoType = 2
)

Jump to

Keyboard shortcuts

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