sourcegraph / srclib-go

Go toolchain for srclib
https://sourcegraph.com/sourcegraph/srclib-go
MIT License
29 stars 13 forks source link

depresolve: Incorrect optimization for "google.golang.org/" import path prefix. #88

Closed dmitshur closed 8 years ago

dmitshur commented 8 years ago

See https://github.com/sourcegraph/srclib-go/blob/4c327dd481924fe3bdf3e9d71604d9b59eab28cb/depresolve/depresolve.go#L36-L40:

// Special-case google.golang.org/... (e.g., /appengine) import
// paths for performance and to avoid hitting GitHub rate limit.
case strings.HasPrefix(importPath, "google.golang.org/"):
    target.ToRepoCloneURL = "https://" + strings.Replace(importPath, "google.golang.org/", "github.com/golang/", 1) + ".git"
    target.ToUnit = strings.Replace(importPath, "google.golang.org/", "github.com/golang/", 1)

That is not valid for the following import path:

google.golang.org/grpc

In reality, it maps to:

https://github.com/grpc/grpc-go

But depresolve.ResolveImportPath incorrectly maps it to https://github.com/golang/grpc.

dmitshur commented 8 years ago

I'm not sure about the performance implications of removing this optimization. Removing it altogether would require more thorough investigation.

For now, I'll fix this by adding the grpc special case handling. It should still be an issue to resolve this more generally in the long term.