Go Learn

󰃭 2013-09-08

Today I decided to try out Go.

What is Go?

Go is a programming language designed and developed at Google. It was designed by really smart people: Robert Griesemer, Rob Pike, and Ken Thompson.

Syntax-wise, it looks a lot like C, except the ending semicolons are optional, and parentheses for if, for, etc are not required.

Here’s a gist showing some syntax:

It’s a fibonacci calculator made using a closure, caching previously calculated numbers.

Features

  • Statically typed (but types can be inferred).
  • Concurrency baked in (goroutines, channels).
  • Garbage collection.
  • Fast compile times.
  • No classes (you attach functions to structs instead).
  • No inheritance (Go makes heavy use of interfaces).
  • No overloading.
  • No pointer arithmetic.

Coding in Go

To learn Go, I first did a quick read of Learn X in Y Minutes to get a grip of the syntax.

Then, I went over to their official website and took the tour.

Afterwards, I wanted to get a working application. Go includes an http server in their official packages, so I decided to make a web application.

After a little searching, I found they had a tutorial aimed at web applications, so I decided to use exactly that. Go documentation rocks!

I followed the tutorial along and was able to get a wiki type of website up and running in about 20 minutes. After that, I decided I wanted to add markdown support to it, and a few more features, like creating new pages and deleting pages.

One thing I really liked about Go is that it comes with a lot of useful packages so you can start working right away. For example, I thought I would have to write some sort of templating system, but Go already comes with one. And it’s context aware! So you don’t have to worry about escaping things!

Packages

Go’s packaging system allows you to get packages from VCS repositories. For example, to add markdown support to my wiki, I added knieriem’s markdown package as a git submodule in my project.

Screenshots of my development process

development process

crud view

crud edit

As usual, my project is on Github.



More posts like this

Learning a Programming Language

󰃭 2014-02-14 | #javascript #programming-projects #ramblings

I’ve heard that if you’re a good programmer, you should be able to pick up a new language in a few days. And I’ve done this myself, I learned the basics of Go a few months ago. Built some command line programs and a web app with it, all in a few days. Yet, what does it take to really learn a new language? To master it? Sure, there are some concepts that translate well from language to language, but some languages have their own thing going on.

Continue reading 


Starry Sky in HTML5 Canvas - Part 1

󰃭 2019-04-13 | #canvas #javascript #programming-projects #tutorials

In my spare time I often enjoy creating visualizations using HTML5 canvas. I’m planning to do a little presentation about this so I thought a good way to get started was to create a blog post explaining how to do a simple one. This tutorial will teach you how to create something like the image below from scratch! IMPORTANT – you can try out the result of this part of the tutorial by visiting this CodeSandbox.

Continue reading 