October 4, 2019

Working with enums in Go

Enums (short of enumerators), identifiers that behave like constants, are useful parts of many languages. Unfortunately, enums in Go aren’t as useful due to Go’s implementation. The biggest drawback is that they aren’t strictly typed, thus you have to manually validate them. Read more

July 10, 2019

Building a live chat with Go, NATS, Redis and Websockets

Building a live-chat server is a good practice for learning a ‘backend’ programming language. You need to provide an uninterrupted stream of data (think WebSockets), message storer and ideally a pubsub mechanism to send a message to all subscribed consumers. Goch is no different, besides HTTP and REST endpoint it uses WebSockets, Redis, and NATS-streaming to support live-chat messaging. Read how it runs and how you can build your own live-chat in Go. Read more

January 28, 2019

Google Datastore with a relational data model

I’ve been working on a medium-sized European software as service (SaaS) for the last two years. Almost everything we use comes from Google, which includes Cloud Datastore as our primary source of truth. I’m not advocating against it - depending on your use-case it might be a great fit. Instead, I’m presenting the issues we have with it (and other NoSQL/document databases) due to our domain models being very relational. Read more

October 28, 2018

Refactoring Gorsk - Why and how

Refactoring source code should be a constant process in software’s lifecycle. I advocate for 20-25% of time spent on developing software to be used on refactoring exclusively. After working with Gorsk in two projects running now in production (one of them being a large SaaS), I’ve found many things I don’t like about it. During the development of those projects I refactored some things, but I decided the base needs to be updated too. Read more

August 30, 2018

Marshal YAML fields into map[string]string

Recently we moved some of our hard-coded web-app configuration values into a YAML file. Arguing aside (YAML vs TOML vs …), YAML does a great job being easily readable by us - humans. By default, the yaml library marshals maps into map[string]interface{}, requiring a small change to get it marshaled into map[string]string. Read more

August 16, 2018

Twisk - Golang RPC starter kit

Twisk, an acronym for Twirp starter kit, helps you get started with a simple Golang RPC framework with protobuf service definitions - Twirp. It features everything from authorization, implemented CRUD on a single entity, logging, configuration and more. Using minimal dependencies, idiomatic code and best practices, it helps you get started with Golang backend API development - both JSON and Protobuf. Read more

June 10, 2018

Serve SwaggerUI within your Golang application

I’ve previously written an Article on generating OpenAPI (Swagger) spec automatically within Golang. It’s the most popular article on this blog since lots of developers are searching for it. In it, I mentioned that in order to serve the swagger.json with SwaggerUI, a Docker instance is required that will serve SwaggerUI. There is an easier way to implement it, and this article will demonstrate how to do it with net/http, Gin and Echo. Read more

May 26, 2018

Working with Go Web Frameworks - Gin and Echo

Recently I spent a lot of time working with both Gin and Echo. Primarily I wrote an open source restful starter kit named Gorsk (GitHub/Blog post). Besides Gorsk, I’m working on two web apps utilizing Gin/Echo. Even though the reasons for (not) using Golang’s ‘Web frameworks’ are mentioned quite often, I have built my own opinion on these. Read more

April 4, 2018

Automate Chrome with Golang and ChromeDP

Until recently I never knew how simple it could be to automate a task in the browser. A client wanted me to build simple automation script for Chrome - it would log into his Drupal website, open Bootstrap settings and change cdn’s to the one found in config file. Sounded bit hard at the beginning, but after playing an hour with chromedp it became quite trivial. Example repo is available on GitHub. Read more

March 26, 2018

Golang restful starter kit - GORSK

There are many ways to write a (RESTful) backend in Go. Most of the available tutorials are way too simple, with all the presented content fitting into a single file (or at most two-three). More complex examples are quite rare, and even most of them miss lots of things for the sake of reducing complexity. That’s one of the reasons I wrote Gorsk - to have a fully functional example of a RESTful backend (in Golang) utilizing best practices, idiomatic code, and minimal dependencies. Read more

2018 © Emir Ribic - Some rights reserved; please attribute properly and link back. Code snippets are MIT Licensed

Powered by Hugo & Kiss.