Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
proposal: wiki: CodeReviewComments: remove guideline against 'this' / 'self' receiver names #38550
The page at https://github.com/golang/go/wiki/CodeReviewComments#receiver-names has this to say about receiver names for struct methods:
This explanation was added in #28475.
But I don't believe this is a good argument:
In fact, there are benefits to using
I am interested in removal of this blessed guideline as a first prerequisite towards removing this as a default lint rule in vet and in other tools.
(However, I would support a vet rule enforcing that the names
The wiki page is a style guideline, and as it says the Go style is not to use names like
I believe that the explanation is accurate. At least in C++, virtual methods are special, and the name
If you want to write code that uses a different style, go ahead. You can also simply ignore the associated lint errors.
The current style guideline has the advantage of internal consistency: the naming convention for a parameter is the same whether or not it's the receiver. This makes sense to me, since in Go the receiver behaves no differently from other parameters.
Also for what it's worth, I've had substantial experience with both Python and C++ and I still prefer the Go style. It feels odd now to name all method receivers the same, even ones of completely unrelated types.