io

package
v0.0.0-...-e7a43b6 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2018 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ASTToByteArray

func ASTToByteArray(ast *ast.File) ([]byte, error)

ASTToByteArray returns a syntax tree as a byte array

func ASTToFile

func ASTToFile(ast *ast.File, file string) error

ASTToFile writes a syntax tree to file

func ASTToString

func ASTToString(ast *ast.File) (string, error)

ASTToString returns a syntax tree as a string

func ByteArrayToAST

func ByteArrayToAST(buf []byte) (*ast.File, error)

ByteArrayToAST composes syntax tree from a byte array content

func ByteArrayToFile

func ByteArrayToFile(content []byte, filepath string) error

ByteArrayToFile writes a buffer to a file

func EnsureDir

func EnsureDir(dir string) error

EnsureDir checks for a dir existence and creates it if not exists

func FileToByteArray

func FileToByteArray(file string) ([]byte, error)

FileToByteArray reads file content and stores it in a byte array

func FileToString

func FileToString(file string) (string, error)

FileToString reads file content and stores it in a string

func NormalizePath

func NormalizePath(ptrStr *string) error

NormalizePath takes a path and resolves ~ to HOME env value and returns abs path

func StringToAST

func StringToAST(str string) (*ast.File, error)

StringToAST composes syntax tree from a string

func StringToFile

func StringToFile(content, filepath string) error

StringToFile writes a strint to a file

func TraceAST

func TraceAST(f *ast.File) error

TraceAST prints out AST file content

Types

type Content

type Content struct {
	Ast *ast.File
}

Content payload in two formats, byte arrays or syntax tree

func NewContent

func NewContent(str string) (*Content, error)

NewContent returns a pointer to a content struct from a string payload

func (*Content) Bytes

func (c *Content) Bytes() ([]byte, error)

Bytes returns the content as a byte array

func (*Content) String

func (c *Content) String() (string, error)

String returns the content as string

func (*Content) Trace

func (c *Content) Trace() error

Trace dumps content

type GoFile

type GoFile struct {
	Path string
	Content
}

GoFile represents a go source code disk resource. Each struct member is a different way of having same info

func NewGoFile

func NewGoFile(filepath string) (*GoFile, error)

NewGoFile returns a brand new GoFile instance

Jump to

Keyboard shortcuts

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