Golang Beego implementing and using CAPTCHA

19 January, 2017

In this small tutorial I'll show you how to use CAPTCHA validation inside your application. We won't be using the builtin CAPTCHA of Beego but instead use another package of GitHub user dchest, and his package captcha.

Golang Beego how to use sessions

18 January, 2017

The official documentation on using sessions in Beego is besides being outdated quite unclear. I'll show you how to use sessions inside your Beego application.

Golang string to int

02 January, 2017

The built in 'strconv' package contains a function named 'Atoi' (ASCII to integer). Which is just a wrapper for the 'ParseInt' function.

Golang creating a worker thread pool using maps

24 July, 2016

This example will show you how to create a worker thread that waits for jobs and working them one by one. We use maps to create a list where we add jobs too. This tutorial will process strings and create bcrypt hashes of it, for simulating purposes.

Golang mgo append to a nested array in a document

24 May, 2016

Small tutorial on how to add/push/append a new element to an array/list inside a document, based on my previous post.

Golang mgo retrieve nested structured arrays

24 May, 2016

Small tutorial on how to retrieve nested arrays/lists from a 'mgo.Find()' result.

Golang transfer a file over a TCP socket

21 May, 2016

In this tutorial I'll demonstrate how to send a file in Go over a TCP connection using a server that sends the file and a client that receives it, I'll try to go into detail as much as possible.

You can download the source code here.

Comments and remarks are more than welcome.

Golang mgo findAndModify auto increment id tutorial

17 May, 2016

Here is a brief explanation for the 'findAndModify()' equivalent for mgo. Instead of 'findAndModify()' we will use 'mgo.Find().Apply()'. I will demonstrate how to use auto incremented ids instead of random unique generated IDs for documents, since mongdb does not have a native way of doing this (because MongoDB is not a relational database).

It work's like this, we create a collection, insert a document in that collection that contains the last generated ID. Every time we call 'findAndModify()', mongoDB will increment the value and we get that new value back, which you should use to insert a new document with.

Generate CRC32 hash of a file in Golang turorial

17 April, 2016

In previous posts I showed how to make a MD5 hash and a SHA1 hash of a file, generating a CRC checksum on a file is however a bit more complicated since it uses a polynomial table. I'll explain everything in depth.

Generate SHA1 hash of a file in Golang example

08 April, 2016

This function is based on my previous post but adapted for the SHA1 algorithm.

Generate MD5 hash of a file in Golang

07 April, 2016

Why generate a MD5 hash of a file?

You may have noticed before on some websites where you download a file, there is some strange string of text around the download link, named "checksum", for example "md5 checksum: dcdfb1413d7fa48c3cab920c0448f236". Now this may look like a bunch of random characters to you but don't be fooled, it's a one-way mathematical hash that correspondents to the file you want to download.

Home