I started playing with Golang(or just Go) this week for the first time. Go is a compiled, statically typed language and I thought it would be a great fit for situations where Node.js, my primary go-to stack, won't be a great candidate for the job. For heavy processing and problems where concurrent-first solutions must be applied.

The first thing I did was to check the online tour on the official site. It's very well structured and has also some exercises to get you started. Wrapping my head around the language was very easy since it has a lot of well-known concepts like pointers and structs, similar to C.

After playing a bit around I thought I would make something using my new learnings and Go. I found a really cool project and wanted to contribute to it. So I thought I will fork it and create a bootstrap application and try to import my fork. But that strange message appeared on my console:

package github.com/kbariotis/imageproxy: code in directory /Users/Bariotis/golang/src/github.com/kbariotis/imageproxy expects import "willnorris.com/go/imageproxy"

what this basically means is that my repo had an explicit [canonical import path]https://golang.org/cmd/go/#hdr-Importpathchecking) set that was forcing the consumer to download it from a particular place and that was the original author's site.

This post explains even more how this works. Since the Go command allows one to import packages from remote servers and a package may live in various places or it can be moved from one place to another, the maintainer must explicitly set the default URL that others must use to import the library, in order to avoid the link rot.

But that confused me a bit since I do this all the time with npm. I can fork a library and import it from my fork directly.

I searched a bit around and found that the simplest thing to do (and didn't think of it) was to import the original repository and the Go command will clone it into my $GOPATH/src directory. From there I could change the git remotes URLs and send any changes onto my fork. Then make a PR to the original repo or change the canonical import path annotation if I wanted to use my fork directly.

Keep this in mind if you're just starting with the Go language. Btw, Goroutines are awesome!