Version: v0.5.1-0...-cc7cbc4 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2021 License: Apache-2.0, BSD-3-Clause Imports: 0 Imported by: 0




This project allows you to generate failing mock types for given interfaces. It is based on the mockery project.

A failing mock type is a type that implements an interface. In case any method returns an error or error pointer, a failing mock type also returns an error.


Use the following tools to set up the project:


To install this tool, run the following command:

dep ensure -add ''


  1. Create an interface for which you want to generate a mock implementation type. For example:

    type Requester interface {
        Get(path string) (string, error)
  2. Add the following line above your interface:

    //go:generate go run {relativeVendorPath}/cmd/failery/failery.go -name=Requester -case=underscore {generationTypeParams}
    type Requester interface {
        Get(path string) (string, error)

    Make sure that the -name parameter value is equal to the name of the interface for which you want to generate the mock implementation.

    Replace values in curly braces with the proper details, where:

    • {relativeVendorPath} is the relative path to the vendor directory of the project.
    • {generationTypeParams} are additional parameters that specify a mock generation type. The -inpkg parameter creates a file in the same package, and the -output {packageName} parameter generates a mock in the {packageName} package.

    For more configuration options, see the mockery documentation.

  3. Run the following command in your project root:

    go generate ./...
  4. See the generated type:

    type Requester struct {
        err error
    // NewRequester creates a new Requester type instance
    func NewRequester(err error) *Requester {
        return &Requester{err: err}
    // Get provides a failing mock Function with given fields: path
    func (_m *Requester) Get(path string) (string, error) {
        var r0 string
        var r1 error
        r1 = _m.err
        return r0, r1


Install dependencies

This project uses dep as a dependency manager. To install all required dependencies, use the following command:

dep ensure -vendor-only
Verify the code

To check if the code is correct and you can push it, run the script. It builds the application, runs tests, checks the status of the vendored libraries, runs the static code analysis, and ensures that the formatting of the code is correct.


The Go Gopher

There is no documentation for this package.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL