Skip to content

Change the target directory into which go get clones the repo #27850

Closed
@EVODelavega

Description

@EVODelavega

What version of Go are you using (go version)?

go version go1.10.4 linux/amd64

Does this issue reproduce with the latest release?

Yes, reproduced with go version go1.11 linux/amd64

What operating system and processor architecture are you using (go env)?

Linux/amd64, specifically Fedora 28

What did you do?

Cloning a private gitlab repository using go get. The url looked something like git.foo.io/main-serivces/subcategory/my-service. I had to add .git explicitly: go get git.foo.io/main-services/subcategory/my-service.git.
Don't think it's relevant, but worth noting: the repo was empty when I cloned it.

What did you expect to see?

I expected/hoped to find my code under $GOPATH/src/git.foo.io/main-services/subcategory/my-service

What did you see instead?

Instead, the path was $GOPATH/src/git.foo.io/main-services/subcategory/my-service.git

There's 2 possible solutions that I'd like to propose.

  1. Add a flag to go get to specify the target path where you want to checkout the package, or a flag to strip the .{git|svn|whatever} from the path. Arguably, this should be the default behaviour, that can be disabled using a flag.
    If this should not be the default behaviour, I'm thinking a flag like -s[trip]=.git might be worth adding.

  2. either change the last catchall regexp in cmd/go/internal/get/vcs.go, or add a next-to-last one that handles generic .git repo's (ie a url containing \bgit\.\b, or simply ending in .git), and trim the .git` from the target directory/path

I'm perfectly happy working on either one of these solutions, depending on which would be the preferred approach. If this is a bad idea, feel free to tell me so, and I'll leave it at that, although I'd like to know why this would not be a useful feature.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions