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

Refactor code to use go/types instead of go/ast #41

Closed
ernesto-jimenez opened this issue Aug 24, 2015 · 7 comments
Closed

Refactor code to use go/types instead of go/ast #41

ernesto-jimenez opened this issue Aug 24, 2015 · 7 comments

Comments

@ernesto-jimenez
Copy link
Contributor

On issue #18 I mentioned that Go 1.5's go/types package I stated that the change should allow simplifying the codebase.

I wanted to see how much work it would mean so I did a quick implementation from scratch using go/types.

The implementation results in ~24% less and the following bugs are fixed: #18 #19 #40

% wc -l $(ls **/*.go | grep -v _test | grep -v fixtures)
      57 main.go
     174 mockery/generator.go
      99 mockery/importer.go
      40 mockery/imports.go
      39 mockery/method.go
     409 total
% wc -l $(ls **/*.go | grep -v _test | grep -v fixtures)
     197 cmd/mockery/mockery.go
       4 doc.go
     254 mockery/generator.go
      81 mockery/parse.go
     536 total
@evanphx
Copy link
Member

evanphx commented Aug 24, 2015

I don't really want to make mockery go 1.5 only. How do we avoid doing that and using go/types?

@ernesto-jimenez
Copy link
Contributor Author

@evanphx before adding go/types to the stdlib there was golang.org/x/tools/go/types, but there are some API differences and we can expect go/types to have a stable API since it's in the stdlib.

Since it's a command-line tool, would it be enough to cross-compile the tool and publish the binaries for people with Go < 1.5?

@dwlnetnl
Copy link
Contributor

Maybe it's a matter of time to deprecate Go < 1.5 support.

@colonelpanic8
Copy link
Contributor

@ernesto-jimenez 's suggestion to release binaries seems good to me...

@arvenil
Copy link

arvenil commented Feb 16, 2016

What about now, since go 1.6 is already here could you reconsider dropping support for go < 1.5? :D
I would like to avoid switching to fork, but looks like it fixes at least 2 big issues with mockery so it kind of looks like a waste to ignore such a nice contribution to library.
And for go < 1.5 people can always use older hash of library.

@evanphx
Copy link
Member

evanphx commented Apr 6, 2016

Let's do this! Time to move on now that most everyone is on 1.5.

@evanphx
Copy link
Member

evanphx commented Apr 7, 2016

It's done! It's in! Thanks so much for the idea and code to get started @ernesto-jimenez!

@evanphx evanphx closed this as completed Apr 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants