Golang: Arrays of Strings

This post is going to be about Golang, arrays and strings. In Go we have more than simple arrays that we know from JavaScript or PHP. They are basically divided into the following:

  • arrays
  • slices
  • maps

This was confusing to me at first, because in basically every language I knew I could change the length of an array by just pushing things to it. Not so; in Go.

Continue reading “Golang: Arrays of Strings”

Tracing or Preventing HTTP Redirects in Golang

In this post we’re going to have a look at how to have a close look at HTTP requests processed by Go and how to prevent automatic redirection through 301, 302 or similar redirects. This is useful both for investigating tracking links from twitter, buffer, bit.ly or email marketing, or to make sure your tools to generate them actually work 😉 For a demo, check out the Redirect Checker Tool

Continue reading “Tracing or Preventing HTTP Redirects in Golang”

On: Too many Frameworks and if you should use one

Web and especially JavaScript frameworks exist quite numerously, but there is also a great deal of controversy about if it’s too many, who should be using a framework, who should be building one and of course the obligatory

The framework I’m using is superior to yours!

discussions en masse.

I just want to give a quick overview of what I think of the matter, because many people have some good points, but my TLDR; version would be: do whatever you want, but don’t tell other people what they should do.

Continue reading “On: Too many Frameworks and if you should use one”

Web Scraping with Golang and goQuery

Web scraping is practically parsing the HTML output of a website and taking the parts you want to use for something. In theory, that’s a big part of how Google works as a search engine. It goes to every web page it can find and stores a copy locally.

For this tutorial, you should have go installed and ready to go, as in, your $GOPATH set and the required compiler installed.

Continue reading “Web Scraping with Golang and goQuery”

Using Sourcegraph Checkup with local file system storage

Checkup is a siteuptime like alternative that will monitor the response times of your website and a bunch of other things.

Setting up the project is a little tricky if you’re new to go, but if you read the Readme and google the error messages you get, you should be perfectly fine.

You can clone the most recent version from their github repository and run it with:

go run cmd/checkup/main.go --store

Using the checkup fs provider

Sadly the documentation is not super awesome yet, but I quickly diffed the changes I made to make the project use the local storage provider instead of relying on aws s3.

Continue reading “Using Sourcegraph Checkup with local file system storage”

Installing Go on Ubuntu / Debian / Linux Mint with godeb

Since I’ve recently started dabbling with Go again, of course I had to install it on my machines that mostly run Linux Mint. One of the usual ways for me to install software through the PPAs was apparently not maintained since a couple of releases ago, but on a ubuntu forum thread I found godeb, which is a small binary command line tool that lets you install your desired version of Go!

Continue reading “Installing Go on Ubuntu / Debian / Linux Mint with godeb”

JSON parsing in Golang

Parsing JSON is a common task for most developers, currently I’m actually finally getting to write slugofy which is supposed to slugify URLs or URL fragments in Go.

In case you’re wondering, slugs are commonly used to generate URLs from the title of a page. Let’s say we have a page title like the Swedish national dish: Swedish national dish: köttbullar, we probably don’t want either the special chars like the ö or the : in there. Also we don’t want whitespaces to show up as %20, so let’s make them dashes instead: swedish-national-dish-koettbullar.

Continue reading “JSON parsing in Golang”

Go(lang) Unit Testing for Absolute Beginners

Unit testing with Go-lang is very simple and the testing library is actually included by default. For test driven development or just for covering the functionality of your code afterwards, unit tests are pretty essential.

This article is about the smallest possible effort we can make to get started with testing. No fancy algorithms or too language specific things, just the bare minimum, so we understand what’s going on and can extend from there on.

Continue reading “Go(lang) Unit Testing for Absolute Beginners”

Taking a stab at the Go Language and file permissions

Go is a C-like language and initially developed at Google, it has caught my attention by some members of the node.js and web development community giving it a shot and also some interesting looking projects. You can check it out at golang.org. Continue reading “Taking a stab at the Go Language and file permissions”