Category Archives: Go

Making Something Crap is Better Than Making Nothing At All

I’ve made something! I’ve made something in Go! And while it is of no use to anyone, I’m so happy, because I didn’t know anything about Go, and now I do know some things :)

All it is is a little app that queries the Instagram API with a search term and displays some images. Big deal right? Who the hell wants that?

Answer: No one. But I learnt a hell of a lot building even this small thing.

You know when you read textbooks, or do tutorials, it feeeels productive and you feel like you’re learning something? But actually, I know I learn a lot better when I make something myself from scratch. It demands something of you more than cut and paste. It helps you figure out if you know something, or if you just read it and can parrot it back.

Now, I’m not saying I KNOW Go, even looking at my repo will show you a nightmare of inefficient, spaghetti code – but I know so much more than I did AND I have that good old confidence of thinking I can figure things out now. Before, Go was just an amorphous concept, something I thought I couldn’t do. Now it’s something I have played around with and it has given me some confidence.

Some things I learnt about Go by building my own little app

  • Using structs, variables and functions
  • Using html templates
  • Passing objects through to the html templates
  • Ranges, conditionals, string manipulation
  • How to use libraries – for example, I used the Instagram API library.

I need to remember this in the future – when trying to learn something, go ahead and do tutorials, etc, but then hack something from scratch yourself. It’s the best way to learn!

Sidenote: I was talking to a male friend who is learning coding, and I gave him this above advice, with the note “Don’t worry if it’s crap, just build it”. And he said “Men (in general), don’t think like that”. Which I thought was such an interesting comment. Is it true? I know of exceptions, but maybe the generalisation is true. Side, sidenote: I’m trying hard to be more like that and to stop being so self deprecating, so I really shouldn’t have said what I made was crap at all.

1 Reply

I’m Still Learning Go

A little while ago I posted about Go when I had just started learning it. I’ve had a bit more of a look now, and I’m going to note down some of the aspects I’m finding most challenging. I think I am finding these most challenging because they aren’t things that I have been explicitly exposed to in Ruby. Many of these notes were found in this excellent introduction to Go by Karl Seguin.
Continue reading

Leave a reply

Starting to Learn Go

A few weeks ago I started a new job. It’s actually kind of a big deal for me, because when I quit my business to start working as a junior developer I assumed it would be quite a few years until I had the freedom I had working for myself again.

However, just 1 year in, and I have a job where I can work remotely… I can’t even believe how lucky I am. My new job has the freedom I love, plus I get to work with super lovely people, AND I am learning new things. Just a couple of the things I’m using at my new job that I didn’t really do before – is using unit tests, haml, and there is a part our app that uses Go.

Go is a language I knew nothing about until my new job, but I’m pretty excited to learn it. Here are some resources that I have been getting started on:

  • This video by Audrey Lim from GopherCon 2015, describes how she learnt Go in just 5 weeks (kind of inspiring, kind of depressing!)
  • The Go Tour helps you get installed and start programming in Go.
  • This Go by Example is exactly what I like – examples!
  • The Way To Go – comprehensive text book type thing
  • This crash course video is 1 hour. He talks super fast, so I wouldn’t recommend it as the first thing you watch, but it brought a lot of things together for me.
  • This short book on Go, gives good explanations beyond starter things – like how to make structs, what pointers are, and more

When I first started looking at the Go files I was pretty confused, but the general layout is:

package main
import "fmt"
func main() {
fmt.Printf("Hello, world.\n")
}

Package main –  This is the namespace, like a class almost. You can have many files with the same package.

Import – This is any libraries you want to use

A main function is required (usually the first func), otherwise a build error will occur.

Some Beginner pointers on Go

  • Each Go application contains one package called main.
  • The standard library of Go contains a lot of packages like ‘fmt’.
  • When the identifier of something  ( of a constant, variable, type, function, struct field, …) starts with an uppercase letter, like Group1, then the ‘object’ with this identifier is visible in code outside the package. Otherwise, it’s only available inside the package.
  • When declaring parameters for a function, After the name of each parameter variable must come its type

I read a bit more about Go and wrote a second post on it.

Leave a reply