golint style warnings

Answered

Hi,

 

I want to get warnings to appear in GoLand that match the golint warnings about common initialisms. i.e. I want GoLand to warn when it sees words like ASCII, URL, JSON etc. (full list is here: https://github.com/golang/lint/blob/738671d3881b9731cc63024d5d88cf28db875626/lint.go#L767)

I don't mind setting up custom linting rules or integrating directly with golint but I can't see how to do either.

Does anyone have instructions on how I could set this up?

Thanks

Gareth

5 comments
Comment actions Permalink
Official comment

At the moment, this feature is not supported. Vote/watch this issue for updates https://youtrack.jetbrains.com/issue/GO-2153

Also, please keep in mind that golint is now officially frozen/deprecated, see https://github.com/golang/go/issues/38968

Comment actions Permalink

Hi Florin,

Thanks for the quick reply. I've voted for that issue, though I don't hold out too much hope as it's four years old!

Are there any plans to allow more customisation of linting in GoLand - custom styles and that type of thing? I know Go is pretty prescriptive but there is still room for interpretation that I'd like to be able to nail down (such as capitalisation).

Cheers

Gareth

0
Comment actions Permalink

Hi Gareth,

 

> Are there any plans to allow more customisation of linting in GoLand - custom styles and that type of thing?

Can you please explain what you'd like to see more than the current ability to enable/disable inspections?

> I know Go is pretty prescriptive but there is still room for interpretation that I'd like to be able to nail down (such as capitalisation)

Go is indeed prescriptive in certain areas, but as I said above, tools like `golint` can be deprecated in time. So, while it's important to maintain a certain style of working, it's also not clear what style should be used. We want to include only inspections that are useful and produce very few, if any, false positives for our users, whenever possible. This is why your feedback in terms of what is useful for you and your team is highly appreciated and welcomed.

0
Comment actions Permalink

I'm looking for some way of defining our own inspections so we can look for recurring patterns that we'd like implemented in a different way. The spellings of words mentioned in the original post is a simple example of this. Sorry if this is a bit woolly, I can't talk about specific code and we're still learning how best to use Go within our team.

I think the "structural search inspection" is similar to what I'd want to do at the moment but I can't select Go files in the "File type" drop down. Is that deliberate?

 

0
Comment actions Permalink

Thank you for the details.

At the moment Structural search is not supported for Go. However, you can watch/vote for that ticket to receive updates, when we'll have them.

A more involved way of doing this would be to create a custom inspection using a plugin that handles your exact needs. That being said, please let us know what kind of issues the IDE should help you avoid and we'll see how we can make the IDE support these cases in the future. If you use the issue tracker, then you can set the visibility to `jetbrains-team` which will allow you to share a bit more context that's not publicly visible.

0

Please sign in to leave a comment.