golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.25k stars 608 forks source link

mockgen: record invocation arguments in generated code #554

Open rogpeppe opened 3 years ago

rogpeppe commented 3 years ago

It's not always obvious how mockgen-generated code has been created, particularly when coming to it without prior knowledge of it. Good practice would be to include a go:generate directive that can be used to regenerate the code, but that's not always done.

Currently the comments on the generated code look something like this:

// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/foo/bar (interfaces: Baz)

// Package mocks is a generated GoMock package.

I propose something along the lines of this:

// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/foo/bar (interfaces: Baz)
//
// Generated by this command:
//    gomock github.com/foo/bar Baz

// Package mocks is a generated GoMock package.
codyoss commented 3 years ago

Hey, thanks for the feature request, I like this idea! I think it would also be useful to record what version of mockgen generated the mock as well.

I would be happy to accept a PR for such a feature 😃