Skip to content

gostaticanalysis/vetgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vetgen

CircleCI GoDoc

vetgen creates vettool with own analyzers.

Insall

$ go get -u github.com/gostaticanalysis/vetgen

How to use

init

$ vetgen init myvet
$ cat myvet/main.go
// This file is generated by vetgen.
// Do NOT modify this file.
//
// You can run this tool with go vet such as:
//	go vet -vettool=$(which myvet) pkgname
package main

// go vet
import (
	"golang.org/x/tools/go/analysis/unitchecker"
	"github.com/gostaticanalysis/vetgen/analyzers"
)

var myAnayzers = []*analysis.Analyzer {}

func main() {
	unitchecker.Main(append(
		analyzers.Recommend(),
		myAnayzers...,
	)
}

add an analyzer

$ cd myvet
$ vetgen add github.com/tenntenn/mychecker
$ cat main.go
// This file is generated by vetgen.
// Do NOT modified this file.
package main

// go vet
import (
	"golang.org/x/tools/go/analysis/unitchecker"
	"github.com/gostaticanalysis/vetgen/analyzers"
	"github.com/tenntenn/mychecker"     // add by vetgen
)

var myAnayzers = []*analysis.Analyzer {
	mychecker.Analyzer,
}

func main() {
	unitchecker.Main(append(
		analyzers.Recommend(),
		myAnayzers...,
	)
}

run

$ go vet -vettool=$(which myvet) fmt