Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Does Stash have Go support?

George Jiglau July 21, 2014

Can I make Stash provide Go packages?

For example, I'd like import code as follows:

import "my.host/key/repo"

This page describes how to add such support: http://golang.org/cmd/go/#hdr-Remote_import_paths

4 answers

5 votes
Dhawal Patel October 30, 2014

Don't like the .git suffix in folders. Stash should add the go meta tag in response.

chaishushan November 24, 2014

I also don't like .git and /scm/.

1 vote
TimP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 22, 2014

Hi George,

Yep! You can. You just need to use the HTTP/S URL in your import statement, i.e.:

import "{hostname}/scm/{project_key}/{repository_slug}.git"

For example, to import the repository "newmath" from the project "TEST" on https://stash.atlassian.com I used:

import "stash.atlassian.com/scm/test/newmath.git"

There does seem to be a deficiency in Go that prevents you from having ~ in the URL, which means you won't be able to use packages hosted in personal repositories (as they contain /~username/) but repositories hosted in projects work just fine.

GO nuts ;)

cheers,

Tim

Peter Dalinis October 24, 2014

This solution does "work", but is far from desirable IMO. The scm in the path can be omitted. The problem is that all your directories will have .git in them as a suffix. It would be really nice to see Atlassian have real support using the http header solution.

chaishushan November 24, 2014

The good package path is: import "{hostname}/{project_key}/{repository_slug}"

Willie Walker March 30, 2015

The extra stuff required in the path when working with go projects in Atlasssian does indeed drive me nuts, so "GO nuts" is a perfect directive. ;-) Any chance we might see a stash improvement in this area soon?

yesnault April 15, 2015

"Any chance we might see a stash improvement in this area soon?" +1

trinitronx May 21, 2017

Yes, the fact that I cannot have a `/~username/` in my repository path is indeed driving me nuts as others have stated.  So it is very fitting to direct users to "GO nuts".

All kidding aside,  it'd be great to be able to use `go get` as intended with **all** Atlassian / Bitbucket repositories, especially and including user "personal repositories".  This bug is holding me back on any real hackathon progress, and the constraints of needing a private repo for company owned code plus needing a personal repo is very much also driving me to "GO nuts".  Maybe I should just publish the company code in a public git repo in order to actually get something done.... oh wait, except that would be personal suicide according to the rules of NDA + capitalist corporatism as dictated by most companies in my country.  Oh well, I guess it's back to working on other private code I can't own with minutes of my life that I'm not allowed to decide what to do with either.

Maybe it's good that this bug is not fixed... maybe enough people will be convinced that sharing is better than keeping things private & to oneself or one company.  Until then... here's to hoping for change.

trinitronx May 21, 2017

On second thought, perhaps my time is better spent trying to shift cultural value memes from the "Orange value meme" of ego-driven unhealthy & isolating consumerist capitalism "up the spiral" towards some sort of more spiritually fulfilling endeavor.  If only society could allow its members to escape the mundane debt-based point system in order to have a place to live.

George Jiglau May 21, 2017

You're either trolling or crazy.

 

Anyway, my fix was to get rid of Atlassian products and just switch to Gitlab.

 

I've been happy ever since.

trinitronx May 22, 2017

Hehe, well I was just frustrated working on a late night hackathon project with very little sleep, and getting stuck on a yak shaving rabbit hole that should've been an easy thing to work around.  All while thinking about the deeper cultural significance that tied into my current problem caused by a private repo, which was a requirement caused by the current cultural paradigm of society, caused by money system, caused by need for food & resources, etc...

 

Anyway, good news:  I was able to figure out how to get this mostly working using the Bitbucket personal repo "~username" path.  Unfortunately, it means you must reference the package name in "import" statements everywhere in your code the same way:

 

import "{hostname}/scm/~{username}/{repository_slug}.git"
import "{hostname}/scm/~{username}/{repository_slug}.git/lib/some-library"
import "{hostname}/scm/~{username}/{repository_slug}.git/lib/some-other-library"

The .git at the end apparently is important, which happened to be my problem.  The other issue now is with this path not matching how glide vendors libraries in the same project, although the project is probably not doing things quite right anyway.

As Tim Pettersen's answer stated, it seems to be a deficiency in go, as without the ".git", it will try to get package metadata by calling the url with "?go-get=1".  For atlassian however, this metadata appeared to not work properly and was somehow messing up the path with a "~username" url.  Additionally, if I tried to use the "git config" "insteadOf" url rewriting capability, it got more confusing.

Anyway, sadly I'm not sure Gitlab is an option for me and sadly I ended up having nothing to show for hackathon this time, but cheers!

 

Stefan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 22, 2017

Hi James,

Further support for "go get" was added to Bitbucket Server (previously Stash) in version 3.8.0 (BSERVDEV-5380), including being able to use a clean import path (i.e. correct metadata is returned for the Go tools to parse). This means you should be able to use an import path without needing to specify the VCS suffix.

Please note that an import path of this form (using metadata to retrieve the clone URL, instead of explitcily stating the clone URL) should not include "/scm".

go get {hostname}/{project_key}/{repo_slug}

It also seems that "go get" now works properley with a tilda (~) in the import path. I did some manual testing (with Stash 3.8.0, when this feature was added, and Bitbucket Server 5.0.1, the latest version), using the latest version of Go tools (1.8.1), and I was able to succesfully use "go get" to install a go package from a personal repository.

Please let me know if you have any further questions.

Kind regards,
Stefan Petrucev
Atlassian Bitbucket

0 votes
Stefan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 27, 2015

Further support for go get was added in Stash 3.8.0.

https://jira.atlassian.com/browse/STASH-5380

Kind regards,
Stefan Petrucev
Atlassian Stash

0 votes
Peter Dalinis October 24, 2014

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events