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

Research and add all GoPkg formats #121

Open
zendern opened this issue Apr 12, 2020 · 1 comment
Open

Research and add all GoPkg formats #121

zendern opened this issue Apr 12, 2020 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@zendern
Copy link
Contributor

zendern commented Apr 12, 2020

  • What are you trying to do?
    Idk man ask @DarthHater .... he added this comment awhile ago ;P

// FIXME: Research the various Gopkg name formats and convert them correctly

  • What feature or behavior is this required for?
    Make sure we are in fact handling all the GoPkg formats that are possible.

  • How could we solve this issue? (Not knowing is okay!)
    Add them and delete that comment once we have the definitive list....and maybe we are good already but this issue if to validate that.

  • Anything else?

cc @bhamail / @DarthHater

@DarthHater
Copy link
Member

Expanding a bit on this:

func convertGopkgNameToPurl(name string) (rename string) {
	switch {
	case githubPattern.MatchString(name):
		rename = githubPattern.ReplaceAllString(name, "golang/github.com/$1/$2")
	case gopkg2Pattern.MatchString(name):
		rename = gopkg2Pattern.ReplaceAllString(name, "golang/github.com/$1/$2")
	case gopkg1Pattern.MatchString(name):
		rename = gopkg1Pattern.ReplaceAllString(name, "golang/github.com/go-$1/$1")
	default:
		rename = "golang/" + name
	}
	return
}

This function was mainly made to coerce some of the goofier golang URLs of old into something a bit more "authoritative". The patterns it looks for are:

var gopkg1Pattern = regexp.MustCompile("^gopkg.in/([^.]+).*")
var gopkg2Pattern = regexp.MustCompile("^gopkg.in/([^/]+)/([^.]+).*")
var githubPattern = regexp.MustCompile("^github.com/([^/]+)/(.*)")

Basically, it would be nice to know if we are missing any! These were just the oddballs we knew of, and are mostly a result of the pre dep and pre go mod versions of how you got dependencies in the Golang world.

@DarthHater DarthHater added enhancement New feature or request help wanted Extra attention is needed labels Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants