Linter for Go's fmt.Errorf message

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)
}
Owner
Comments
  • build(deps): bump golang.org/x/tools from 0.3.0 to 0.4.0

    build(deps): bump golang.org/x/tools from 0.3.0 to 0.4.0

    Bumps golang.org/x/tools from 0.3.0 to 0.4.0.

    Release notes

    Sourced from golang.org/x/tools's releases.

    gopls/v0.4.0

    • Improved support for working with modules (@​ridersofrohan). A detailed walk-through of the new features can be found here. A quick summary:
      • Use the -modfile flag to suggest which modules should be added/removed from the go.mod file, rather than editing it automatically.
      • Suggest dependency upgrades in-editor and provide additional language features, such as formatting, for the go.mod file.
    • Inverse implementations (@​muirdm). "Go to implementations" on a concrete type will show the interfaces it implements.
    • Completion improvements (@​muirdm). Specifically, improved completion for keywords. Also, offer if err != nil { return err } as a completion item.
    • Jumping to definition on an import statement returns all files as definition locations (@​danishprakash).
    • Support for running go generate through the editor, via a code lens (@​marwan-at-work).
    • Command-line support for workspace symbols (@​daisuzu).

    Opt-in:

    • Code actions suggesting gofmt -s-style simplifications (@​ridersofrohan). To get these on-save, add the following setting:
    "[go]": {
    	"editor.codeActionsOnSave": {
    		"source.fixAll": true,
    	}
    }
    
    • Code actions suggesting fixes for type errors, such as missing return values (goreturns-style), undeclared names, unused parameters, and assignment statements that should be converted from := to = (@​ridersofrohan). Add the following to your gopls settings to opt-in to these analyzers. In the future, they will be on by default and high-confidence suggested fixes may be applied on save. See additional documentation on analyzers here.
    "gopls": {
    	"analyses": {
    		"fillreturns": true,
                    "undeclaredname": true,
                    "unusedparams": true,
                    "nonewvars": true,
    	}
    }
    
    • Further improvements in the support for multiple concurrent clients (@​findleyr). See #34111 for all details.

    For a complete list of the issues resolved, see the gopls/v0.4.0 milestone.

    gopls/v0.3.4

    gopls/v0.3.3

    • Support for workspace symbols. (@​daisuzu)
    • Various completion improvements, including fixes for completion in code that doesn't parse. (@​muirdm)
    • Limit diagnostic concurrency, preventing huge spikes in memory usage that some users encountered. (@​heschik)
    • Improved handling for URIs containing escaped characters. (@​heschik)
    • Module versions from "go list" in pkg.go.dev links. (@​ridersofrohan)

    ... (truncated)

    Commits
    • aee3994 gopls/internal/lsp/fake: in (*Workdir).RenameFile, fall back to read + write
    • fe60148 go.mod: update golang.org/x dependencies
    • c9ea9a7 gopls/internal/regtest: add a test for the case when the renaming package's p...
    • bf5db81 gopls/internal/lsp/cache: improve ad-hoc warning for nested modules
    • aa9f4b2 go/analysis: document that facts are gob encoded in one gulp
    • bdcd082 internal/gcimporter: skip tests earlier when 'go build' is not available
    • 2ad6325 gopls/internal/lsp/cache: expand ImportPath!=PackagePath comment
    • 52c7b88 gopls/internal/robustio: only define ERROR_SHARING_VIOLATION on Windows
    • 4f69bf3 gopls/internal/lsp/cache: narrow reloadOrphanedFiles to open files
    • 6002d6e gopls/internal/regtest/misc: test Implementations + vendor
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • build(deps): bump golang.org/x/tools from 0.2.0 to 0.3.0

    build(deps): bump golang.org/x/tools from 0.2.0 to 0.3.0

    Bumps golang.org/x/tools from 0.2.0 to 0.3.0.

    Release notes

    Sourced from golang.org/x/tools's releases.

    gopls/v0.3.0

    Note: gopls now loads your entire workspace, where “workspace” is directory you opened in your editor.

    In module mode, you must open your module root (directory containing the go.mod file) or a subdirectory.

    In GOPATH mode, you must open your GOPATH/src or a directory within it. If you have a large GOPATH and you open your GOPATH as your workspace root, gopls may be very slow to load. Please see #36899 for further information.

    • Autocompletion from unimported packages is on by default. You will get completions for something like fmt.Printf even if “fmt” isn’t imported yet. (@​heschik)
    • Workspace-scoped references, rename, and go to implementation. These features use your workspace root as the search scope, so behavior will vary based on the directory you open in your editor. This may result in unexpected behavior. (@​muirdm, @​matloob)
    • Workspace-wide diagnostics. You will now see errors in your entire workspace, rather than just in your currently open files. Analysis errors will only be shown for packages with currently open files.
    • Watch file changes on disk. This allows users to switch branches without reloading their editors. Also, changing configurations no longer requires an editor reload.
    • GOPATH vendoring is fully supported. Previously, some features would ignore vendor directories, causing errors if packages weren't in GOPATH. (@​heschik)
    • New autocompletion suggestions for type conversions. Improved completions for literal candidates and variadic functions. Better rankings, including rankings for builtin functions and keywords. (@​muirdm)
    • Highlighting improvements: Highlighting now applies not only to variables, but also to fields, methods, types, and imports. Additional highlighting helps visualize control flow in loops and functions. Highlighting of single character variables has better support. (@​ridersofrohan)
    • Documentation on hover includes links to pkg.go.dev for exported symbols. (@​Southclaws)
    • Improved support for cgo dependencies. All features now work for packages that have cgo dependencies. Authoring cgo packages is still not supported, but improvements are scheduled for Go 1.15 (see #35721). (@​heschik)
    • Deep completions are now on by default. This feature of completion will search the fields and methods of all available candidates to see if there are any more candidates with the expected type. As an example, say you have imported the context package and are calling a function that takes a context.Context as a parameter. In the case that you don’t have a variable of that type in scope, deep completions will suggest context.Background() and context.TODO(). (@​muirdm)

    Opt-in:

    • staticcheck analyses remain opt-in and can be enabled by setting "staticcheck": true in your gopls settings.
    • Go 1.14 will support running the go command without modifying the user’s go.mod file. This new feature is used in gopls to show diagnostics and suggest edits in a user’s go.mod file rather than change the file without the user noticing. Currently, gopls will suggest removing unused dependencies and warn the user if there is a parse error in the go.mod file. Enable this behavior by using the go1.14 beta and setting "tempModfile": true in your gopls settings. (@​ridersofrohan)

    gopls/v0.2.2

    • Fix concurrent map read and write when a file is created (CL 210199).
    • Fix issue that caused errors to show up when a new file was created (CL 209978).

    gopls/v0.2.1

    • Fix for parse errors showing up as errors on the whole package (CL 206597).
    Commits
    • 502c634 go.mod: update golang.org/x dependencies
    • bd04e32 internal/jsonrpc2_v2: eliminate a potential Accept/Dial race in TestIdleTimeout
    • d41a43b internal/jsonrpc2_v2: fix a potential deadlock when (*Conn).Close is invoked ...
    • 3057465 gopls/doc: Add plugin for Lapce to gopls documentation
    • ba92ae1 internal/persistent: avoid incorrect map validation due to multiple keys
    • 9474ca3 gopls/doc: clarify go work use
    • 003fde1 internal/gcimporter: use nondeprecated go/packages mode bits
    • 5050657 gopls/fake: add semantic token modifiers to fake editor
    • 88a3548 gopls/coverage: repair coverage.go
    • 8e0240a internal/regtest/workspace: permanently skip TestDeleteModule_Interdependent
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • build(deps): bump golang.org/x/tools from 0.1.12 to 0.2.0

    build(deps): bump golang.org/x/tools from 0.1.12 to 0.2.0

    Bumps golang.org/x/tools from 0.1.12 to 0.2.0.

    Release notes

    Sourced from golang.org/x/tools's releases.

    gopls/v0.2.0

    • Many improvements to autocompletion. In particular, support for completions of array, slice, map, and function literals (@​muirdm).
    • A new diff algorithm (github.com/sergi/go-diff) that improves handling of line endings on different operating systems (@​ianthehat).
    • Improved caching and memory usage (@​stamblerre).
    • Command-line support for links, suggested fixes, and imports (@​kalmanb).
    • Command-line support for references, signature, and symbols (@​rentziass).
    • Command-line support for rename (@​hartzell).

    Opt-in:

    • Get diagnostics from staticcheck by configuring "staticcheck": true in your gopls settings (@​ianthehat).
    • Get autocompletion of unimported packages and symbols by configuring "completeUnimported": true in your gopls settings (@​heschik).
    Commits
    • f112c43 go.mod: update golang.org/x dependencies
    • 207f456 go/internal/gcimporter: bump version number in skew check
    • 65196ca gopls/README.md: fix wording around supported Go versions
    • 6128030 gopls/internal: support renaming packages with int. test variants
    • 649df2e go.mod: mark as requiring -compat 1.16
    • 91311ab gopls/internal/lsp/cache: better import path hygiene
    • 9eda97b go/analysis: enable a test that applies after go list behavior change
    • b50d7ba gopls: minor cleanup of standalone package support
    • 502b93c gopls/internal/lsp: tolerate missing end position in RelatedInformation
    • d67c3ad internal/imports: repair warnings from default analyzers
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • build(deps): bump golang.org/x/tools from 0.1.11 to 0.1.12

    build(deps): bump golang.org/x/tools from 0.1.11 to 0.1.12

    Bumps golang.org/x/tools from 0.1.11 to 0.1.12.

    Commits
    • b3b5c13 internal/lsp/cache: invalidate packages with missing deps when files are
    • 39a4e36 internal/lsp/regtest: only run /default tests with -short
    • f157068 internal/lsp/regtest: allow sharing memoized results across regtests
    • 8ccb25c internal/lsp: treat struct tags as string type
    • 6c8a6c4 internal/lsp: suppress parameter hint when argument matches parameter
    • c83f42d internal/lsp: update inlay hints documentation to include go snippets
    • 8b47d4e all: update dependencies
    • 7600454 gopls: update dependencies
    • 2a6393f internal/lsp: Refactor to share logic with rename
    • 4375b29 cmd/auth/cookieauth: delete unreachable os.Exit
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • build(deps): bump golang.org/x/tools from 0.1.10 to 0.1.11

    build(deps): bump golang.org/x/tools from 0.1.10 to 0.1.11

    Bumps golang.org/x/tools from 0.1.10 to 0.1.11.

    Commits
    • 1d19788 internal/lsp/cache: always compute IsIntermediateTestVariant
    • 4a8620f internal/lsp/cache: move metadata fields to a new metadataGraph type
    • a3d129c internal/lsp/cache: extract module load errors when go.work is used
    • 6bfd3a4 Revert "internal: temporarily disable tests so we can land CL 410955"
    • 5ca4cc8 internal: temporarily disable tests so we can land CL 410955
    • 63dfc2d internal/lsp/cache: two minor optimizations
    • 030812f internal: remove unneeded FileSets
    • 2417911 go/analysis/internal/checker: add -test flag for single/multi-checkers
    • 43cce67 go/analysis: document need for deterministic Fact encoding
    • af82757 cmd/callgraph: add test of -algo=vta
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • build(deps): bump golang.org/x/tools from 0.1.9 to 0.1.10

    build(deps): bump golang.org/x/tools from 0.1.9 to 0.1.10

    Bumps golang.org/x/tools from 0.1.9 to 0.1.10.

    Commits
    • 6799a7a internal/lsp/source: canonicalize objects in reference/rename requests
    • 54a569a internal/imports: use first quote when matching import path
    • 40370f8 go/internal/gcimporter: add a test case for issue 51219
    • 24806f2 go/analysis: add tests check for calling *F methods in fuzz func
    • dff7c5f go/internal/gcimporter: guard against infinite recursion with recursive
    • 49d48a0 go/analysis/passes/composite: allow InternalFuzzTarget
    • 198cae3 go/ssa: split pkg() into different cases for *Package and *types.Package
    • ee31f70 internal/lsp: add completion for use directives
    • 622cf7b internal/lsp/cache: copy workFile when invalidating workspace
    • e7a12a3 go/ssa: add type substitution
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
[mirror] This is a linter for Go source code.

Golint is a linter for Go source code. Installation Golint requires a supported release of Go. go get -u golang.org/x/lint/golint To find out where g

Dec 23, 2022
Staticcheck - The advanced Go linter

The advanced Go linter Staticcheck is a state of the art linter for the Go programming language. Using static analysis, it finds bugs and performance

Jan 1, 2023
A Go linter to check that errors from external packages are wrapped

Wrapcheck A simple Go linter to check that errors from external packages are wrapped during return to help identify the error source during debugging.

Dec 27, 2022
A linter that handles struct tags.

Tagliatelle A linter that handles struct tags. Supported string casing: camel pascal kebab snake goCamel Respects Go's common initialisms (e.g. HttpRe

Dec 15, 2022
a simple golang SSA viewer tool use for code analysis or make a linter
a simple golang SSA viewer tool use for code analysis or make a linter

ssaviewer A simple golang SSA viewer tool use for code analysis or make a linter ssa.html generate code modify from src/cmd/compile/internal/ssa/html.

May 17, 2022
The Golang linter that checks that there is no simultaneous return of `nil` error and an invalid value.

nilnil Checks that there is no simultaneous return of nil error and an invalid value. Installation & usage $ go install github.com/Antonboom/nilnil@la

Dec 14, 2022
Go linter which checks for dangerous unicode character sequences

bidichk - checks for dangerous unicode character sequences bidichk finds dangerous unicode character sequences in Go source files. Considered dangerou

Oct 5, 2022
Go linter that checks types that are json encoded - reports unsupported types and unnecessary error checks

Checks types passed to the json encoding functions. Reports unsupported types and reports occations, where the check for the returned error can be omited.

Oct 7, 2022
Linter for PostgreSQL

Использование Проверить миграции: oh-my-pg-linter check ./migrations/*.sql Добавить директории с дополнительными проверками (переопределение - кто пос

Nov 25, 2021
containedctx detects is a linter that detects struct contained context.Context field

containedctx containedctx detects is a linter that detects struct contained context.Context field Instruction go install github.com/sivchari/contained

Oct 22, 2022
World's spookiest linter

nosleep The world's spookiest linter nosleep is a golang-ci compatible linter which checks for and fails if it detects usages of time.Sleep. Why did y

Oct 15, 2022
Go linter to analyze expression groups: require 'import' declaration groups

grouper — a Go linter to analyze expression groups Installation

Jun 19, 2022
funcresult — a Go linter to analyze function result parameters

Go linter to analyze function result parameters: require named / unnamed function result parameters

Jan 27, 2022
nostdglobals is a simple Go linter that checks for usages of global variables defined in the go standard library

nostdglobals is a simple Go linter that checks for usages of global variables defined in the go standard library

Feb 17, 2022
Goalinter-v1: Goa framework (version1) linter

goavl: Goa framework (ver1) linter goavlは、goa version1(フォーク版)のlinterです。開発目的は、goa

Jul 28, 2022
misspelled word linter for Go comments, string literals and embedded files

gospel The gospel program lints Go source files for misspellings in comments, strings and embedded files. It uses hunspell to identify misspellings an

Aug 6, 2022
Same as fmt.Errorf but with stack trace.

Annotation with stack trace for go1.13 Go 1.13 contains support for error wrapping. Now you can add additional information to an error by wrapping it

Dec 25, 2020
Gos: Armed Golang 💪 ( solutions for go module, goproxy, cross compilation, etc.)
Gos: Armed Golang 💪 ( solutions for go module, goproxy, cross compilation, etc.)

The current gos is still an alpha version, welcome more heroes to comment and improve it ?? , you can add more commands to it, or modify something to make it perform better.

Sep 15, 2022
Prometheus Common Data Exporter can parse JSON, XML, yaml or other format data from various sources (such as HTTP response message, local file, TCP response message and UDP response message) into Prometheus metric data.
Prometheus Common Data Exporter can parse JSON, XML, yaml or other format data from various sources (such as HTTP response message, local file, TCP response message and UDP response message) into Prometheus metric data.

Prometheus Common Data Exporter Prometheus Common Data Exporter 用于将多种来源(如http响应报文、本地文件、TCP响应报文、UDP响应报文)的Json、xml、yaml或其它格式的数据,解析为Prometheus metric数据。

May 18, 2022
Go-commitlinter - simple commit message linter
Go-commitlinter - simple commit message linter

go-commitlinter go-commitlinter is simple commit message linter. Quick Start go

Oct 8, 2022