gostaticanalysis / zapvet

Analyzer: zapvet is static analysis tool for zap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

zapvet

pkg.go.dev

zapvet is static analysis tool for zap.

  • fieldtype: fieldtype finds confliction type of field

Install

You can get zapvet by go install command (Go 1.16 and higher).

$ go install github.com/gostaticanalysis/zapvet@latest

How to use

zapvet run with go vet as below when Go is 1.12 and higher.

$ go vet -vettool=$(which zapvet) ./...

Analyzers

fieldtype

fieldtype finds confliction type of field.

package a

import "go.uber.org/zap"

func f() {
	zap.String("id", "100")
	zap.Int("id", 100)       // want `"id" conflict type Int vs String`
	zap.Any("id", "100")     // OK - ignore
	zap.Reflect("id", "100") // OK - ignore
	zap.String("xxx", "100") // OK
}

Analyze with golang.org/x/tools/go/analysis

You can get analyzers of zapvet from zapvet.Analyzers. And you can use them with unitchecker.

About

Analyzer: zapvet is static analysis tool for zap

License:MIT License


Languages

Language:Go 100.0%