Category: Golang Code

Read a File to String

This is a matching post to “Writing to a File” and explains how to simply get the contents of a file as text and print it to screen. There are different ways to achieve this in Go – all valid. In this guide...

Read More

Working with POST Request Data

This is an overview post (pun intended) about how to work with post request data sent to an endpoint via HTTP. This is slightly different to data stored in query parameters sent in the url and has to be handled differently....

Read More

Go Get: Install All Packages

Go has a simple built in way to download packages. If you’ve programmed in Go, you’ve likely used the go get command before (view docs). It often works something like this: go get -u Which is...

Read More

JSON Encode – Pretty Print

Is JSON for computers or humans to read? Well, hopefully with this snippet it can be for both. Instead of just dumping all the json in one line, we instead format it and indent it for readability purposes. Using the...

Read More