Taking Screenshots with Headless, The Chrome Debuggping Protocol (CDP) and Golang

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”

Golang and the Clipboard (mdclip)

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)”

Golang TOML Configs Example: MySQL Connection

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”

Deploying your Golang App without Docker

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”

Building a Go(lang) API with echo and MySQL

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”

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”