Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time



outparamcheck is a static code checker for Go based on errcheck. It verifies that functions that take output parameters defined as interface{} types are passed pointers to an object rather than a concrete object.

A canonical example of this is the json.Unmarshal function, which has the following definition:

func Unmarshal(data []byte, v interface{}) error

As noted in the godoc ("Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v"), the v must be a pointer so that the results of the operation are available to the caller. However, because v is declared as an interface{}, the compiler allows non-pointer values to be passed to the function and the failure is not detected until runtime.

outparamcheck allows these classes of checks to be performed using static analysis. By default, this tool checks the calls to encoding/json.Unmarshal, encoding/safejson.Unmarshal and It is possible to use a configuration file to add to the set of functions that are checked.


go get -u


Run outparamcheck with the default checks on all packages within the current directory:

./outparamcheck ./...


Additional checks can be configured using JSON. The JSON can be provided to the check directly as a parameter or by specifying the path to a file that contains the configuration. The tool accepts a single JSON map where the keys are the name of the function to be checked and the values are an array that specifies the parameter indices of the "out" parameter (the parameter that must be a pointer). For example, in order to check that the first (index 0) parameter of the function is an output parameter, the JSON would be the following:

    "": [0]

The configuration is provided to the tool using the -config flag. The value for the flag is treated as a literal JSON string unless it starts with the @ character, in which case it is interpreted as the path to a JSON file. The checks that are specified in the configuration are run in addition to the built-in checks. It is not possible to override or ignore the built-in checks.

Example invocation configured using JSON directly:

./outparamcheck -config '{"":[0]}' ./...

Example invocation using JSON specified in the file config.json:

./outparamcheck -config @config.json ./...


outparamcheck is a Go static code analysis tool that verifies that output parameters are used correctly








No packages published

Contributors 4