Skip to content

Commit

Permalink
pkg -> internal, analyzer via constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonboom committed Jul 22, 2021
1 parent 02e9fdc commit a9bc339
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 128 deletions.
238 changes: 119 additions & 119 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package main
import (
"golang.org/x/tools/go/analysis/singlechecker"

"github.com/Antonboom/errname/internal/analyzer"
"github.com/Antonboom/errname/pkg/analyzer"
)

func main() {
singlechecker.Main(analyzer.ErrName)
singlechecker.Main(analyzer.New())
}
14 changes: 8 additions & 6 deletions internal/analyzer/analyzer.go → pkg/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ import (
"golang.org/x/tools/go/ast/inspector"
)

// ErrName is the analyzer itself.
var ErrName = &analysis.Analyzer{
Name: "errname",
Doc: "Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`.",
Run: run,
Requires: []*analysis.Analyzer{inspect.Analyzer},
// New returns new errname analyzer.
func New() *analysis.Analyzer {
return &analysis.Analyzer{
Name: "errname",
Doc: "Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`.",
Run: run,
Requires: []*analysis.Analyzer{inspect.Analyzer},
}
}

type stringSet = map[string]struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestErrName(t *testing.T) {
"unusual/errortype",
"unusual/newfunc",
}
analysistest.Run(t, analysistest.TestData(), ErrName, pkgs...)
analysistest.Run(t, analysistest.TestData(), New(), pkgs...)
}

func Test_getPkgFromPath(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit a9bc339

Please sign in to comment.