The Best Go Content on the Internet


Simple messaging framework using Go TCP server and Kafka

Contributed by

I needed to create a simple framework to provide my endpoint devices ( doesn’t matter which platform they run on ) the option to send and receive messages from my backend. I require those messages to be managed by a message broker so that they can be processed in an asynchronous way. The system contains 4 main layers, this article section is mainly about the first one: 1. TCP servers - Needs to maintain as many TCP sockets in synch with the endpoints as possible.

Read more...

Go 1.10

Contributed by

Table of contents Language changes Operating Systems support Tooling Environment Variables go build go install go test gofmt go fix pprof Runtime CGO support Debugging Assembly support Packages Closing notes Introduction Go 1.10 is the first major release after the announcement of the plans towards Go 2.0 at GopherCon 2017. There are a number of exciting changes which I’ll cover below as well as some changes in the behavior of either tools or Go APIs which might result in an unexpected behavior compared to the previous change.

Read more...

Create a Slack bot with golang

Contributed by

Create a Slack bot with golang Introduction In this post we’ll look at how to set up a quick Slack bot that receives messages (either direct or from channel) and replies to the user. I’ve been an IRC user for many years and always loved setting up bots, whether for sports scores, weather, or something else entirely. Recently I’ve actually had an opportunity to implement my first Slack bot and figured I would document the process for others!

Read more...

TensorFlow and Go

Contributed by

This year I helped organize several online security challenges, one of which is Blacklight. Among the things I was asked to do, was creating a POC for a specific challenge, to prove that it’s possible to solve in a reasonable time. That challenge was one I face occasionally in my everyday life, not always with success: break a captcha. The task that requires breaking the captcha is disabling a security camera, to break into a room, without the security camera capturing your face.

Read more...

Using Go Templates

Contributed by

Go templates are a powerful method to customize output however you want, whether you’re creating a web page, sending an e-mail, working with Buffalo, Go-Hugo, or just using some CLI such as kubectl. There’re two packages operating with templates — text/template and html/template. Both provide the same interface, however the html/template package is used to generate HTML output safe against code injection. In this article we’re going to take a quick look on how to use the package, as well as how to integrate them with your application.

Read more...

Method Closures: You Can't Do That In Go

Contributed by

Neugram is a scripting language that sticks very close to Go. Go statements are Neugram statements, you can import Go packages, scripts can be compiled to Go programs, and types look just like the equivalent Go types at run time (which means packages built on reflection, like fmt, work as expected). These requirements put a lot of restrictions on the design of Neugram. This post is about one such restriction on methods that I did not discover until I tried to use it without thinking.

Read more...

Make Your Build Better With Mage

Contributed by

Many Go projects can be built using only Go’s wonderful built-in tooling. However, for many projects, these commands may not sufficient. Maybe you want to use ldflags during the build to embed the commit hash in the binary. Maybe you want to embed some files into the binary. Maybe you want to generate some code. Maybe you want to run a half dozen different linters. That’s where a build tool comes into play.

Read more...

Managing goroutine lifecycles with run.Group

Contributed by

I stumbled over this idiom for managing goroutine lifecycles when I was writing OK Log. Since then I’ve found uses for it in nearly every program I’ve written. I thought it’d be nice to share it. Motivation My programs tend to have the same structure: they’re built as a set of inter-dependent, concurrent components, each responsible for a distinct bit of behavior. All of these components tend to be modeled in the same way, more or less: whether implemented as structs with methods or free functions, they’re all things that are running: doing stuff, responding to events, changing state, talking to other things, and so on.

Read more...

Go execution tracer

Contributed by

Introduction Ever wondered how are your goroutines being scheduled by the go runtime? Ever tried to understand why adding concurrency to your program has not given it better performance? The go execution tracer can help answer these and other questions to help you diagnose performance issues, e.g, latency, contention and poor parallelization. The tool is available since go 1.5 and works by instrumenting the go runtime for specific events, such as: Creation, start and end of goroutines Events that block/unblock goroutines (syscalls, channels, locks) Network I/O related events Syscalls Garbage collection All this data is collected by the tracer without any kind of aggregation or sampling.

Read more...

Building medical reports in Go

Contributed by

This article is about how we at Mendelics changed our report system from Python to Go using gofpdf library, why we did this change, how we planned it and some insights we got along the way. Some Context Before I dive into some technical aspects let me introduce to you guys what Mendelics does. Mendelics is Brazilian laboratory which process DNA analysis in order to find genetic diseases. We use a technique called NGS (Next Generation Sequencing) to process blood samples and at the end of some steps we input all the DNA information into a Go application in a human readable way.

Read more...