Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package as library so gometalinter can use it #4

Open
atombender opened this issue Mar 29, 2017 · 6 comments · May be fixed by #15
Open

Package as library so gometalinter can use it #4

atombender opened this issue Mar 29, 2017 · 6 comments · May be fixed by #15

Comments

@atombender
Copy link

I've started using this tool, but it's annoying that I can't get inline errors in my editor. Integrating it into gometalinter would be an obvious step, I think. For that to happen, I suspect some changes will be needed to make the API publicly importable.

@BurntSushi
Copy link
Owner

I'd be open to that. I'm not sure when I'd get around to it though.

@atombender
Copy link
Author

You know, I thought gometalinter actually used linters as libraries. But I now see that it merely invokes them as command-line tools. (Probably not very efficient — I bet most of them use the standard Go libs to parse the AST and do something with it — so that surprised me.) So it should be possible and fairly trivial to add support into gometalinter without any additional modifications.

@BurntSushi
Copy link
Owner

BurntSushi commented Mar 29, 2017

@atombender That's interesting. go-sumtype can take quite a bit of time to run on medium sized projects, and a lot of that time is spent loading the entire source tree into an AST and type checking it, including vendor directories. (It would be possible to do this more efficiently I think, and I tried, but I got to a point where I'd have to end up re-implementing GOPATH.) But if all the linters do this and they are independent of each other, then yeah, I can see that being a drag.

@atombender
Copy link
Author

Indeed, gometalinter turns out to be very slow if you enable too many linters, precisely because they're all doing a lot of work. It runs them in parallel, I believe. It even has a deadline system to prevent running amok.

I'm sure it would be possible to get a big performance boost from turning linters into libraries which can then ask the caller for an AST. The AST can then be cached across lint runs. Last I checked, gometalinter wasn't a server, but it probably should be, like gocode.

@ifross89
Copy link

ifross89 commented Jun 6, 2021

Hi, I realise that this thread is over 4 years old but I just stumbled across it. I think this is a useful tool and would like to be able to integrate it with https://github.com/golangci/golangci-lint.

As far as I can tell it looks like the easiest way would be to use the golang.org/x/tools/go/analysis package and moving the logic into a subdirectory so that the Analyzer can be imported.

I have put together a POC that does this and was wondering if it is worth cleaning it up & finishing it to submit a PR?

@BurntSushi
Copy link
Owner

@ifross89 Yeah! I think that sounds great. Thank you. :-)

@ifross89 ifross89 linked a pull request Jun 7, 2021 that will close this issue
diogo464 pushed a commit to diogo464/go-sumtype that referenced this issue May 1, 2022
diogo464 pushed a commit to diogo464/go-sumtype that referenced this issue May 1, 2022
Remove comment about ListPeers being unsafe (fixes BurntSushi#4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants