Setting up a Go IDE

I want to learn Go, and to do that I want to have a nice IDE that allows me to execute a build, run some tests and see what the errors are, all from within the IDE.

Doesn’t sound like much of an ask though, does it? Well there’s a bit of a learning curve out there with regard to setting up an Go environment. I’ve managed to pull something together that suits me, and maybe it’ll suit you too. First off, there are a few options* that you can follow:

1) Use VIM — the following gives you some idea on how to setup VIM for Go. I didn’t follow this approach as I’m not as great with VIM as I could be, and I don’t want to have the frustrations of VIM put me off from learning Go.

2) Use ATOM — ATOM is an IDE from Github, and go-plus provides an improved Go experience for the Atom Editor. This looks like a nice extension, but I want to execute my app as well as having the nice features that go-plus gives you, such as autocomplete, formatting, code quality checks etc. Atom & Go Plus may very well work for you, and if it does please add some tips to the comments section of this doc — sharing is good.

3) Use Sublime Text — This is the approach I have followed, principally because I use Sublime a lot and have a license, but also because I can get the nice formatting and validation features combined with the ability to execute my app from within the IDE as well. Below is what I’ve ended up with:

To get to this point, I followed the following steps:

  1. Install Go — I downloaded the Go Tools from the golang site
  2. Set your GOPATH and GOROOT. Given that I am on OSX, I set it from the terminal by adding the following to the ~/.bash_profile
  3. 1. export GOPATH=/Users/davidmcg/Dropbox/Github/gocode
  4. 2. export GOROOT=/usr/local/go
  5. Add $GOPATH/bin:$GOROOT/bin to your PATH variable — again I added this to ~/.bash_profile
  6. Install Sublime Text — you can easily get Sublime Text from here
  7. Install the package control for Sublime Text by following these steps
  8. Once you have package control installed, you’ll want to install 2 packages:
  • GoSublime — Provides code completion and other IDE-like features such as syntax checking as you type, code formatting and removing unused imports.
  • Sublime-build — The official Sublime Text package for Go build system integration. Golang Build is a Sublime Text package for compiling Go projects. It provides integration between Sublime Text and the command line go tool.

9. To install these packages, run the following bring up the command palette and start typing Package Control: Install Package then press return or click on that option to activate it.

You will be presented with a new Quick Panel with the list of available packages. Type GoSublime or sublime-build and press return to install each package individually.

Configuring GoSublime

To configure GoSublime, you need to configure Sublime Text to run a number of commands on the save of the .go file. The commands will check the code quality, and apply formatting. First, you need to access the settings file for your user, within Sublime Text:

Once you access this section, you’ll need to paste in the following. Note — you’ll need to change your path to match your own system. [CREDIT– I got this from Jonathan Gautheron’s excellent medium post ]

{
 “env”: {
 “GOPATH”: “YOUR GO PATH GOES HERE”,
“PATH”: YOUR PATH GOES HERE”
 },
 “fmt_cmd”: [“goimports”],
 “on_save”: [{
 “cmd”: “gs9o_open”, “args”: {
 “run”: [
 “sh”,
 “go build . errors && go test -i && go test && go vet && golint .”
 ],
 “focus_view”: false
 }
 }],
 “autocomplete_closures”: true,
 “complete_builtins”: true
}

Additionally, you will need to install the golint and goimports tools. Golint prints out style mistakes, and goimports removes unneeded import statements from your code. To install these tools, type the following in a terminal:

go get -u github.com/golang/lint/golint
go get golang.org/x/tools/cmd/goimports

Configuring Sublime-build

So, we have source formatting occurring, but the next step is to be able to actually run our app from within Sublime Text. Thats where sublime build comes in. You should have installed the sublime build package in step 4.2 above. Once you’ve done that, you’ll need to select it as the build system within Sublime Text, as follows:

And once you have done that, then set the ‘Tools | Build With’ value to be ‘Go Run’ And thats you setup.

Once you have done these steps, you can hit the following commands:

  • ⌘ S (Save) — will run the GoSublime on save commands and format your code, check syntax and make sure the imports are correct.
  • ⌘ B (Build) — will run your app for you, with output in the Sublime console window. Note, you can set this value to be go run, go test, go install from the Build With setting. Each time you press ⌘B, it will execute that command.

One final thing — as per Jonathan Gautheron’s medium post, I have also set Sublime Text to use the excellent Predawn theme. The following providesinstructions to set this up for yourself.

Please feel free to point out anything that I may have missed/could have done better. Good luck and happy learning!

* There are other Go Editors out there — the following provides some more details on these other editors. I just wanted to use Sublime Text 🙂

The Three Attributes

Level-Up-DSI’m Davey, and I’m an architect with @KainosSoftware. As part of my job I get to work with a lot of great people, from young cubs that haven’t yet graduated, to old timers that have lots of experience. Part of my role is to be a coach that can guide people on how to develop their career and themselves, but also I interview a lot of people wishing to join the company, and people who wish to progress their career from within as well.

I wanted to share with you some attributes that I think are good for people to have; attributes that I certainly look for and and things that I try to develop in myself. This isn’t a list to say that you need to know technology X or have achieved certification Y, it’s more like a few guiding points that can help you on your journey — no matter if you want to be a software developer, tree surgeon or movie director.

The first attribute is called having a ‘growth mindset. In essence, a growth mindset means adopting the mental model of trying to improve yourself, and if your fail, its not because you cant do what your trying to do, but that you cant do it ‘just yet’ — you need to work at it to develop it, and that takes practice. Think of it like ‘levelling up’ your own abilties.

I think a growth mindset is really important to have, because each and every one of us has something to learn and something to improve upon — but for some of us there is a barrier there to even trying. Maybe it’s fear that you wont know what your doing, maybe your a senior person in a company that doesnt want to look silly in front of others or maybe its because you think it’ll be too hard to even start — your overwhelmed before you even begin.

My advice to you is to just give it a go. Instead of saying ‘I don’t know this or I’m not smart enough’, say ‘I don’t know it yet’. From a practical point, you absolutely still need to put in the effort, but the key is not giving up if you hit your inevitable first hurdles.

Say you want to learn how to code — you need to devote time each and every day. You’ll never learn it all in one go, but I honestly believe that if you keep trying, things will begin to ‘stick’ and one day you’ll find yourself not being an amateur anymore. At the moment I am learning Go, and I’m reading and trying out as much as I can. Will I remember it all? Not a chance, but some things are starting to stick and maybe in a few weeks or months I’ll know enough.

The second attribute I think is important is having a positive attitude, meaning that it’s really easy to think something sucks, or to moan about your job or your manager, or to feel that something is going to be so pants that you don’t want to do it.

I spent around 2 years onsite in Bristol for 3, sometimes 4 days a week at a time, working on a massive Government project, which was tough, but it was also a really great learning experience. When my involvement came to an end, I really fancied having some time at home on a Belfast based project. However, a new role in London came along that was way outside anything I’d done before — and I was going to be doing that 4 days a week, on my own, and I really didn’t fancy it. In fact I was firmly of the view that I was going to say ’No’.

Then I thought about it; I was basing my perception of this new role on what my previous role was like. I didn’t have any facts to base my opinion on; it was just a pure negative emotion to the unknown. I figured then that I should give it a go, and base any decisions on facts — facts about what the project was like, the people, the travel aspect, being away from home, being on my own etc. It’s my 6th week now and I love it — travel is down to a good ratio and I am doing things and learning things that I never would have had the chance to do, if I’d said no. I even had my wife over for the weekend, and it was excellent.

My advice to you is to just give it a go. Instead of saying ‘no’, say ‘I’ll try it and see’. That way your basing decisions on facts, rather than emotions, and if anything you minimise the risk of future regret because at least you’ll know for sure what it would have been like.

The third attribute which I think is good to possess is self-awareness. We all have a mental model of what we think we are like as a person and what our strengths and weaknesses are. However, this model we have of ourselves is rarely accurate as we often over-value some aspects of our abilities and undervalue others.

I believe we should all be actively seeking feedback from others as much as possible on what they think we could do better, as this feedback will help align our own perception of ourselves with the reality of what others think.

Saying that, don’t assume all feedback is 100% accurate , but instead look for the common themes that appear over time or from a number of people. Maybe you didnt realise that you are aggressive with a customer or passive in group sessions. My colleague Steven, has some excellent guidance on giving good feedback.

So to summarise, I think the attributes above will really help you on your journey to improving as a person or within your career. Certainly, I for one really value people that try to embody these attributes and I hope to be such a person myself — let me know how I’m getting on!