go-quickfix: github.com/motemen/go-quickfix Index | Files | Directories

package quickfix

import "github.com/motemen/go-quickfix"

Package quickfix provides functions for fixing Go ASTs that are well typed but "go build" refuses to build.


Package Files


func QuickFix Uses

func QuickFix(fset *token.FileSet, files []*ast.File) error

QuickFix a file set.

func RevertQuickFix Uses

func RevertQuickFix(fset *token.FileSet, files []*ast.File) error

RevertQuickFix a file set.

type Config Uses

type Config struct {
    Fset     *token.FileSet
    Files    []*ast.File
    Dir      string
    TypeInfo *types.Info
    MaxTries int

Config for quickfix.

func (Config) QuickFix Uses

func (c Config) QuickFix() (err error)

QuickFix rewrites AST files of same package so that they pass go build. For example:

v declared but not used             -> append `_ = v`
"p" imported but not used           -> rewrite to `import _ "p"`
no new variables on left side of := -> rewrite `:=` to `=`

TODO implement hardMode, which removes errorneous code rather than adding

func (Config) QuickFixOnce Uses

func (c Config) QuickFixOnce() (bool, error)

QuickFixOnce apply the fixes once.

func (Config) RevertQuickFix Uses

func (c Config) RevertQuickFix() (err error)

RevertQuickFix reverts possible quickfixes introduced by QuickFix. This may result to non-buildable source, and cannot reproduce the original code before prior QuickFix. For example:

`_ = v`        -> removed
`import _ "p"` -> rewritten to `import "p"`

type ErrCouldNotLocate Uses

type ErrCouldNotLocate struct {
    Err  types.Error
    Fset *token.FileSet

ErrCouldNotLocate represents a file not found error.

func (ErrCouldNotLocate) Error Uses

func (e ErrCouldNotLocate) Error() string

type ErrorList Uses

type ErrorList []error

ErrorList represents a collection of errors.

func (ErrorList) Error Uses

func (errs ErrorList) Error() string


cmd/goquickfixThe goquickfix command quick fixes Go source that is well typed but go refuses to compile e.g.

Package quickfix imports 8 packages (graph) and is imported by 6 packages. Updated 2020-01-30. Refresh now. Tools for package owners.