Documentation ¶
Index ¶
- Variables
- func Organize(filename string, input []byte) (output []byte, err error)
- func SeparateValues(filename string, input []byte) (output []byte, err error)
- type Change
- type FileWriter
- type Replacer
- type Tools
- func (f *Tools) Add(filename string, src []byte) error
- func (f *Tools) AddDir(dir string) error
- func (f *Tools) AddFile(filename string) error
- func (f *Tools) AddFiles(files ...string) (err error)
- func (f *Tools) ChangedFiles() (changed []string)
- func (f *Tools) Changes() (changed []Change)
- func (f *Tools) Organize(filename string) (output []byte, err error)
- func (f *Tools) OrganizeAll() (err error)
- func (f *Tools) OrganizeFiles(files ...string) (err error)
- func (f *Tools) SeparateValues(filename string) ([]byte, error)
- func (f *Tools) WriteFiles(writer FileWriter) (err error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrDeclNotFound = errors.New("Declaration not found") ErrPackageMismatch = errors.New("Different package declarations found") )
Functions ¶
Types ¶
type FileWriter ¶
type Tools ¶
type Tools struct {
// contains filtered or unexported fields
}
func (*Tools) Add ¶
Add will attempt to add the given source to the file set and parse the content. If the filename already exists in the file set then fs.ErrExist is returned. Otherwise any parse errors are returned
func (*Tools) AddDir ¶
AddDir will add all the *.go files in the given directory to the local file set. Each file will be parsed. If any parsing errors occur processing stops and the associated error is returned
func (*Tools) ChangedFiles ¶
ChangedFiles returns a list of filenames whose content has changed during the course of processing
func (*Tools) Changes ¶
Changes returns a slice of Change structs containing information about each file that was changed
func (*Tools) OrganizeAll ¶
func (*Tools) OrganizeFiles ¶
func (*Tools) SeparateValues ¶
SeparateValues analyzes the file and will group const and var blocks by type. SeparateValues will only manipulate declarations that are within parenthesized blocks, ie:
const ( Int1 int = iota Int2 Int3 Int4 Str1 string = "string1" Str2 = "string2" Str3 = "string3" Str4 = "string4" )
Becomes:
const ( Int1 int = iota Int2 Int3 Int4 ) const ( Str1 string = "string1" Str2 = "string2" Str3 = "string3" Str4 = "string4" )
func (*Tools) WriteFiles ¶
func (f *Tools) WriteFiles(writer FileWriter) (err error)
WriteFiles will write all the changed files using the supplied FileWriter. If an error is encountered processing stops and the error is returned