3

I'm using GoLand IDE for developing Go applications. I decided to use this as lots of things worked out of the box and I'm used to JetBrains IDEs (Android Studio, AppCode, IntelliJ) and I feel very effective with the learned keyboard shortcuts.

Today, I wanted to enable golint on the project I'm working on, however, I didn't find any standard, simple way to add golint to GoLand.

How can I have the linter go through my code and display a warning or error in JetBrains GoLand? I don't want to rely on the command-line tool to execute the command every time, I want to have it in the editor.

Based on the golint output, it seems like it should not be too hard to integrate the output (it includes the file path, line, column, and the error in each line) and display it as an error right in the editor (with the little red lamp).

I followed the only guide I found, Configure GoLand with golint, but unfortunately, I don't consider it a good enough solution. The end result of that tutorial is that the IDE open a "console" at the bottom of the page, and it just outputs the command result in the IDE. I want to find a way to include it within my code.

Vince Varga
  • 6,101
  • 6
  • 43
  • 60
  • 1
    1) I'm not a GoLand user 2) From what I see from [GoLand tickets](https://youtrack.jetbrains.com/issues/GO?q=golint), there is no desire/plan to implement actual linter integration, devs prefer implementing it as a native Inspections instead (as it's faster and provide more control like quick fixes, suppressing etc etc). That comes from quite old tickets (2016/2017) .. but even one that has recent comments (e.g. https://youtrack.jetbrains.com/issue/GO-2220) still suggests that dev want to go that way. File Watcher seems to be the best way for the moment. For on demand execution: External Tools – LazyOne Aug 14 '19 at 11:27
  • Personally I prefere to decide myself when to run golint over my code. As it only provides suggestions for writing better code I think it could be quite annoying to get those warnings in some situations. I do always check my code at some point and try to follow the suggestions, but I don't do this all the time. However, golint helped me a lot to write better code in Go. – Peter Gloor Aug 14 '19 at 11:30

2 Answers2

-1

You can add Makefile in project.

then run make lint when you need.

I currently use it like this.

beer
  • 42
  • 5
-2

it's an interesting question . Becauese i hava the same trouble like this. the terminal remind the golint not found . I try to add the order 'golint' to zsh . But I found the Golang IDE's preference -- tool --file watching , then you can add the template , the 'golangci-lint' is the tool that you want , though it's not 'golint'. You could use it

  • I haven't used golangci-lint recently, but when I did the last time its output was totally different from what golint returns. It turned out, that it uses a whole bunch of linters, but the real "golint" is missing in the standard configuration. After I changed the call to include "golint", the result was much better, but still not the same as I've got with golint. – Peter Gloor Aug 14 '19 at 11:21
  • try 'golangci-lint' ? – youze liang Aug 14 '19 at 15:44
  • As mentioned in my comment, I did. It was on Windows. Maybe it's different on Linux. I'm not interested in the other checks 'golangci-lint' provides. In general when using GoLand 'go fmt' and 'golint' is enough for me. By the way, the guide mentioned in the question works for me, but I disabled it, because most of the time there is a reason I'm aware of why I get the warnings and therefore I find them annoying. I rather prefere to manually run 'golint' from the terminal from time to time. – Peter Gloor Aug 15 '19 at 09:04