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

add a script for finding popular, but unused projects #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adamdecaf
Copy link
Member

  • popular: the more godoc importers the more popular
  • unused: long time since last commit? few issue updates/comments

Issue: #14

@adamdecaf
Copy link
Member Author

adamdecaf commented Sep 12, 2018

Here's an example run:

name                                           stars last commit (days) importers
github.com/go-martini/martini                  10264 478                2096
github.com/docker/libcontainer                 1037  664                1363
github.com/cihub/seelog                        1183  356                1118
github.com/bmizerany/pat                       1133  398                434
github.com/justinas/alice                      1630  329                328
github.com/google/gxui                         4138  1010               264
github.com/hoisie/web                          3122  454                166
github.com/braintree/manners                   828   461                140
github.com/bradfitz/http2                      1674  974                82
github.com/goraft/raft                         1883  1227               74
github.com/yhat/scrape                         1444  658                44
github.com/rcrowley/goagain                    1791  389                41
github.com/docker/libchan                      2329  326                30
github.com/rsms/gotalk                         884   295                15
github.com/gtank/cryptopasta                   1346  472                13
github.com/JoelOtter/termloop                  902   315                10
github.com/olebedev/when                       879   319                8
github.com/tleyden/open-ocr                    908   493                6
github.com/haxpax/gosms                        1157  437                6
github.com/pravj/geopattern                    961   495                6
github.com/alexflint/gallium                   3591  542                3
github.com/rakyll/coop                         1212  1076               2
github.com/codahale/sneaker                    784   610                1
github.com/kshvmdn/fsql                        3493  264                1
github.com/tobyhede/go-underscore              977   1175               1
github.com/mop-tracker/mop                     933   314                1                                   

@adamdecaf
Copy link
Member Author

Is this useful so far? I can easily add some sorting.

Copy link
Member

@acln0 acln0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice. I'd like to request a few minor adjustments before we merge, though.

Besides the comments in the review, please squash the PR to one commit too.

Thanks.

main.go Outdated
if err != nil {
return -1, fmt.Errorf("problem loading %s: %v", req.URL, err)
}
if resp.Body != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The net/http documentation says "The http Client and Transport guarantee that Body is always non-nil, even on responses without a body or responses with a zero-length body."

I don't think we need this if statement.

main.go Outdated

doc, err := html.Parse(resp.Body)
if err != nil {
panic(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just return the error here. No need to panic.

main.go Outdated
func scrapeGodocImports(importPath string) (int, error) {
req, err := http.NewRequest("GET", "https://godoc.org/"+importPath, nil)
if err != nil {
panic(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return -1, err please, instead of panicking.

main.go Outdated
},
})
if err != nil {
panic(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's log err to standard error and bail out more gracefully than this. Avoid panic please.

main.go Outdated
}
}

func createGithubClient(ctx context.Context) *github.Client {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function should return an error. Currently, it prints a message to standard error if the github token isn't available, but then it continues creating the client regardless.

main.go Outdated
var (
ctx = context.Background()

ghClient = createGithubClient(ctx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this inside of main, please, and let's handle the error it will return more gracefully, by bailing out, instead of continuing.

main.go Outdated
)

var (
ctx = context.Background()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should avoid this. For now, let's pass context.Background() to all things that need it, explicitly.

If the context we use changes in the future, it'll be easier to spot at a glance and adjust.

@acln0
Copy link
Member

acln0 commented Sep 12, 2018

Oh, something else too. I only just now noticed that this vendors dependencies, but it is using modules as well. Isn't that strange? I thought modules and vendoring were incompatible.

@adamdecaf adamdecaf force-pushed the init-script branch 2 times, most recently from 614b967 to 08a6a8c Compare September 12, 2018 21:07
@adamdecaf
Copy link
Member Author

@acln0 Thanks for the review. I dropped vendor/, but it's still used by go build. This script requires the internet already.

@adamdecaf
Copy link
Member Author

adamdecaf commented Sep 12, 2018 via email

@acln0
Copy link
Member

acln0 commented Sep 13, 2018

Thanks. This looks pretty good now.

I guess the next question is if we want to have a main.go in the repository root, or if we should move it to cmd/something.

Ping @theckman for review and further thoughts.

Copy link
Member

@theckman theckman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the option is between using modules and vendoring, I'd prefer we do what we need to have a functioning vendor directory. I'd like to make sure the binary is buildable no matter the state of any of its dependencies.

Can you please update this PR to add a vendor directory that ensures the script will build?

main.go Outdated
@@ -0,0 +1,115 @@
package main
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this cmd/finder/main.go or something similar.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a // import "github.com/gofrs/help-requests/cmd/finder" comment here too?

Perhaps a package-level comment would be nice too, like here https://github.com/golang/tools/blob/master/cmd/stringer/stringer.go

@adamdecaf
Copy link
Member Author

adamdecaf commented Sep 17, 2018

Added vendor/ back. Updated the script a bit. There are still a lot of -1 godoc counts coming back. I think we should try a manual refresh on godoc.org to grab their count. Thoughts?

Edit: I updated the example: #29 (comment)

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

Successfully merging this pull request may close these issues.

None yet

3 participants