The Best Go Content on the Internet


Using a JSON File as a Database Safely in Go

Contributed by

There are definitely problems with using a json file as a database, but sometimes the simplicity of no extra dependencies makes it an attractive option. The two biggest problems are performance and managing concurrent reads and writes. We can’t do much about performance, but with Go, managing concurrent reads and writes is a breeze! Below is a walk through of a method for managing file access so that a json file can safely be used as a database.

Read more...

Probabilistic Data Structures for Go: Bloom Filters

Contributed by

In part one, I talked about some interesting probabilistic data structures.. In part two, I will discuss a more common approximate data structure: Bloom filters and their variations. Bloom filters A set is a collection of things. You can add things to the set, and you can query the set to see if an element has been added. (We’ll ignore deleting elements from the set for now.) In Go, we might use a map[string]struct{} or map[string]bool to represent a set.

Read more...

goquery: a little like that j-thing

Contributed by

A little over 2 and a half years ago I started playing with that new language called Go. Coming mostly from .NET and node.js, I was at first intrigued by its concurrency features and its lack of object inheritance, and impressed by the quality of the team behind it. Fast-forward to today and Go is now my go-to (oh please), day-to-day language, and I’m lucky enough to use it both at work at splice and in my personal projects.

Read more...

Writing file systems in Go with FUSE

Contributed by

Motivation Some time ago, I decided I wanted to solve my own storage needs better, and I realized that I can’t just rely on synchronizing files. I needed a filesystem that combines the best of three worlds: local files, network file systems, and file synchronization. This project is called Bazil, as in bazillion bytes. To make Bazil possible, I needed to be able to easily write a filesystem in Go. And now you can, too, with bazil.org/fuse.

Read more...

Easy Docker Deployment with Hooks and Captain Hook

Contributed by

Deploying with “git push” the Docker Way Many people have asked me how we set up the GopherAcademy blog to automatically deploy when we push a commit. In this Go Advent 2014 article I’m going to walk through the process so you can see what is involved and decide if it’s right for your setup. Why Deployment can be the hardest part of any project. Docker certainly makes that step easier but the ecosystem is still young, and if you want a smooth workflow you’ve got to patch a few things together yourself.

Read more...

Patchwork Toolkit - Lightweight Platform for the Network of Things

Contributed by

Patchwork is a toolkit for connecting various devices into a network of things or, in a more broad case - Internet of Things (IoT). A tl;dr picture describing the idea behind it is shown below. Considering you as a hacker/hobbyist, the Patchwork toolkit can be expressed as follows: you take your favourite electronics (bunch of sensors, LED strip, robot-toys, etc), connect them to a pocket-size Linux box, install Patchwork, and after some quick configuration you get RESTful APIs, MQTT data streams, directory of your devices and services, their discovery on the LAN with DNS-SD/Bonjour, and a damn-sexy, open source real-time dashboard based on Freeboard.

Read more...

Nigel's WebDAV package

Contributed by

Nigel Tao and Nick Cooper have been working on a new WebDAV package for the golang.org/x/net repository. The package is still in its formative stages, so this isn’t a review of the package itself. Instead what I want to discuss is the design of one of the package’s types, and how it made me re-evaluate some of my ideas about Go package design. The Handler type The central type in the WebDAV package is the Handler, which I’ve reproduced below type Handler struct { // FileSystem is the virtual file system.

Read more...

Reading config files the Go way

Contributed by

In the middle of writing my blog engine dynocator, I wondered about the best possible way to read data from a config file. My first approach was to read line by line from the file and use the wonderful strings package to parse the data I want. Another approach revolved around using regexp to seek out the info from the file. But these approaches were both very hacky and involved dealing with a lot of string operations, which I’m not a big fan of.

Read more...

Macaron: Martini-style, but faster and cheaper

Contributed by

Macaron is a high productive and modular design web framework in Go. It takes basic ideology of Martini and extends in advance. Why another web framework? The story began with the Gogs project, it first uses Martini as its web framework, worked quite well. Soon after, our team found that Martini is good but too minimal, also too many reflections that cause performance issue. Finally, I came up an idea that why don’t we just integrate most frequently used middlewares as interfaces(huge reduction for reflection), and replace default router layer with faster one.

Read more...

String Matching

Contributed by

How do you search for a string? If it’s just once, strings.Index(text, pattern) is probably your best option. The standard library currently uses Rabin-Karp to search the text for the pattern. However, there are lots of different cases for string searching, each of which has its own set of “best” algorithms. Fortunately for us, many of them already have implementations in Go. index/suffixarray What if you had a single text you wanted to do lots of searches through for different patterns?

Read more...