Golang has fantastic support for actions that are supposed to happen concurrently (at the same time) without blocking the thread, they are called goroutines and are used by simply putting
go in front of a function.
The functions prefixed with
go will run “on their own” and the rest of your code will continue to run.
In order to gather results or
returns from the functions, you commonly make use of a channel. Channels are the collecting “buckets” that will receive what your goroutines write to them.
Continue reading “Goroutines, Channels and awaiting Asynchronously Operations in Go”
Go is a great language by many accounts. When I first got started with Go, I didn’t have a lot of experience with programming languages that required a specific workspace or a lot of setup.
Go requires you to set 2 or 3 variables, add stuff to your
$PATH (what?) and also expects you to put your files in a certain directory structure. This can be a bit offputting when you’re used to just doing whatever you want.
Full disclosure, this is a less accurate and less informative version of How to Write Go Code from the official website.
Continue reading “Illustrated Guide to getting started with Golang”
govendor is a dependency manager for Go. Go get gets you pretty far when it comes to installing dependencies at first, but when you want to deploy your project or when you want to pin the right version of your dependency it’s not necessarily appropriate to use.
With govendor you can, like with
npm or other tools specify which version of your dependency your project uses, which is a huge benefit for systems that are required to be somewhat stable.
Continue reading “Managing Dependencies with Govendor (Heroku, Dokku)”
When you want to deploy a dead-simple Go API and you don’t really have the urge to learn Docker and large scale deployment (although certainly a useful skill), you have come to the right tutorial.
We’re going to have a quick look at setting up running a golang web app on a Linux VPS without spending more than 10 minutes on it.
Continue reading “Deploying Go Apps with Systemd in 10 Minutes (without Docker)”
I’ve been dabbling with Go and more specifically gin again and I needed a very quick and dirty authentication for a pet project.
Typically I don’t recommend HTTP / basic auth to protect resources, but for this project I didn’t have a database and I was just serving some markdown files here and there.
gin is one of my favourite web frameworks for go, because it has a lot of really cool middlewares, it’s a bit like the express or hapi of go.
Continue reading “Go, Gin and HTTP / Basic Auth”
There’s multiple Go drivers to connect to the Chrome Debugging Protocol in order to either run automated tests or to take responsive screenshots of websites. Let’s explore some of the options that are available for taking screenshots and how to use them from within Go.
Continue reading “Taking Screenshots with Headless, The Chrome Debuggping Protocol (CDP) and Golang”
I recently wrote a couple of lines of Go again, mainly to see if I could write a cross platform clone of a two line shell script in Go (which actually makes it like 69 lines, but whatever).
So I wrote
mdclip to compile a file from markdown to HTML and put it in my clipboard (so I can paste it into my WordPress editor). Now you could scroll down to the comment box and go like
Continue reading “Golang and the Clipboard (mdclip)”
Let’s have a look at how to split application code and configuration for your Golang app. As an example I’d like to show how to use TOML to load your database configuration.
I came to write this because I was dabbling with exporting WordPress posts to TOML front matter / hugo and needed to be able to swap out database servers for development and production servers.
Continue reading “Golang TOML Configs Example: MySQL Connection”
How to deploy an app written in Go? That’s one of the questions I had when I first wanted to get something online after playing with Go for a while. Thinking back I think the first project I got online, was probably the redirect checker which is explained in detail here: Tracing or Preventing HTTP Redirects in Golang
When you just want to get stuff running, you probably don’t want to learn a container system, but just get it out there which is exactly what we’re going to have a look at in this post.
Continue reading “Deploying your Golang App without Docker”
In this post we’ll have a look at how to build a MySQL backed API with Go and echo. This is part of the series that explains how we did photographerexcuses.com
The site is a Vue.js single page app, that gets its data (the excuses) from the Go API. We are storing the excuses in MySQL, because we can easily edit them at the same time with MySQL workbench or similar tools that don’t require flat files, git or other methods that would be more annoying to deal with.
Continue reading “Building a Go(lang) API with echo and MySQL”