Skip to content

Warashi/wrapmsg

Repository files navigation

wrapmsg

Coverage Status

wrapmsg is Go code linter. this enforces fmt.Errorf's message when you wrap error.

Example

// OK 👍🏻
if err := pkg.Cause(); err != nil {
  return fmt.Errorf("pkg.Cause: %w", err)
}

// NG 🙅
if err := pkg.Cause(); err != nil {
  return fmt.Errorf("cause failed: %w", err)
}

Install

go install github.com/Warashi/wrapmsg/cmd/wrapmsg@latest

Usage

You can use wrapmsg as vettool.

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

You can also build your linter with singlechecker or multichecker. In this way, you can use --fix option to autocorrect.

package main

import (
	"github.com/Warashi/wrapmsg"
	"golang.org/x/tools/go/analysis/singlechecker"
)

func main() {
	singlechecker.Main(wrapmsg.Analyzer)
}

About

Linter for Go's fmt.Errorf message

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages