goFile

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoFile

type GoFile struct {
	// contains filtered or unexported fields
}

GoFile holds information about a GO file

func New

func New(filename, packageName, packagePath string) *GoFile

New will create a new GO file representation

Note that the filename cannot contain the folderpath, and the packageName/packagePath refers to the package that the file will belong to

func NewTestFile

func NewTestFile(filename, packageName, packagePath string) *GoFile

NewTestFile will create a new GO test file, with the "_test" filename suffix

Note that the 'filename' cannot contain the folderpath, and the 'packageName'/'packagePath' refers to the package that the file will belong to

func (*GoFile) AddCode

func (f *GoFile) AddCode(newSourceCode string)

AddCode will append the given string to the file source code body (below imports)

Note that the given string is expected to be valid go code. This method doesn't do any checks

func (*GoFile) Name

func (f *GoFile) Name() string

Name will return the name of the file, without the folderpath

func (*GoFile) PackageName

func (f *GoFile) PackageName() string

PackageName will return the name of the package that the file belongs to

func (*GoFile) Save

func (f *GoFile) Save(headerTitle, folder string) error

Save will save the file to disk, ready to be compiled

The headerTitle param is used to fill the signature header, at the beginning of the file (usually, the library name)

func (*GoFile) SourceCode

func (f *GoFile) SourceCode(headerTitle, filepath string) ([]byte, error)

SourceCode will return the content of the file, with the 'package' and 'import' keywords

The filepath param is used to optimize the file imports. It must contain the folderpath and filename information. Example: <folderpath>/<filename>

The headerTitle param is used to fill the signature header, at the beginning of the file (usually, the library name)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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