GithubHelp home page GithubHelp logo

Comments (13)

dsymonds avatar dsymonds commented on June 17, 2024

Interesting. Can you narrow it down to a single Go source file, and point
me at it?

from lint.

natebrennand avatar natebrennand commented on June 17, 2024

Unfortunately I can't, I tried running it on each directory individually but golint did not panic. Here is the repo for reference: https://github.com/natebrennand/twiliogo
Is there a better way to get it to execute on a whole repo with sub directories than golint **/*.go?

from lint.

natebrennand avatar natebrennand commented on June 17, 2024

tried combining directories, it will panic when run on common and twiml simultaneously. This was the smallest combination of directories that I could get to panic.

golint twiml/*.go common/*.go

from lint.

tsuna avatar tsuna commented on June 17, 2024

I'm seeing this issue too, and it only happens when I list all the files of my project too. If I do one package at a time, or try to remove some files, it passes. It's hard to nail down which file causes the problem when there are 12k LOCs.

I added a recover() in github.com/golang/lint.(*file).walk() to print f.filename at the point that it crashes, and noticed it was always the same file. I've been running while golint the/file.go; do :; done for a while now, I can't reproduce the crash with this file alone. :-/

Also even when I do get it to crash, the crash is nondeterministic (it often but not always crashes).

from lint.

dsymonds avatar dsymonds commented on June 17, 2024

I believe I know the cause, and will try to fix it this weekend.

from lint.

dsymonds avatar dsymonds commented on June 17, 2024

The underlying problem is that golint only operates on a single package at a time, and was behaving poorly if provided with files from different packages since that horribly confused the go/types package. I'm adding some code to fail more gracefully, but you'll need to do something like

  find <path> -type d | xargs -L 1 golint

to run golint on everything in a repo.

Having golint automatically shard the input file list by package might be a reasonable feature request, but right now I'm going to fix this panic only.

from lint.

natebrennand avatar natebrennand commented on June 17, 2024

thanks for the suggestion

from lint.

tsuna avatar tsuna commented on June 17, 2024

After the last couple changes, it seems like golint is now confused when I pass files from multiple packages together.

$ make lint
find . -type f -name '*.go' | xargs golint &>lint; :
if test -s lint; then cat lint; rm lint; exit 1; else rm lint; fi
./foo/bar.go is in package foo, not qux
make: *** [lint] Error 1
$ grep package foo/bar.go
package foo

from lint.

dsymonds avatar dsymonds commented on June 17, 2024

That's working as intended.

$ golint -h
Usage of golint:
        golint [flags] # runs on package in current directory
        golint [flags] package
        golint [flags] directory
        golint [flags] files... # must be a single package
...

Golint operates on a single package. See #58 for the feature request issue and a workaround.

from lint.

tsuna avatar tsuna commented on June 17, 2024

So you don't want to break existing stuff that might not expect a return 1 when lint is found, but you don't mind breaking existing stuff that was passing a list of files in argument. :(

I'll change our Makefiles but it's annoying because there is no consistent way anymore to "lint everything" and people don't generally update their golint frequently (if at all). So what version of golint they have depends on when they first ran go get.

from lint.

tsuna avatar tsuna commented on June 17, 2024

It boils down to this:

for dir in `find . -type f -name '*.go' -exec dirname {} ';' | sort -u`; do golint $dir; done

But that only works for those with the latest version of golint. Maybe time to add a flag to recursively lint everything under a certain directory?

from lint.

dsymonds avatar dsymonds commented on June 17, 2024

On 16 September 2014 11:39, Benoit Sigoure [email protected]
wrote:

So you don't want to break existing stuff that might not expect a return 1
when lint is found, but you don't mind breaking existing stuff that was
passing a list of files in argument. :(

No, that's misrepresenting my stance. Backward compatibility is not a
relevant concern on exit codes for me.

from lint.

dsymonds avatar dsymonds commented on June 17, 2024

On 16 September 2014 11:43, Benoit Sigoure [email protected] wrote:

It boils down to this:

for dir in find . -type f -name '*.go' -exec dirname {} ';' | sort -u; do golint $dir; done

But that only works for those with the latest version of golint. Maybe
time to add a flag to recursively lint everything under a certain directory?

Did you read #58, like I suggested? It's simpler than that:

find . -type d | xargs -L 1 golint

from lint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.