Using Go, we often make HTTP calls these days using net/http, which result in a response of type io.ReadCloser… which are hard to read for the layman (like me). What we really want to the response in the form of a string which we can read. This post will talk about how to convert these ReadCloser into strings.
First we’ll look at the problem, then we have two different solutions.
Because ReadCloser is a struct object, we can’t print it out using fmt/log.
Generating UUIDs in Go
UUIDs (Universally Unique Identifiers) serve as a standard for generating identifiers that are unique across time and space. In this blog post, we’ll explore how to generate UUIDs in Go using the google/uuid package. These can be especially useful when generating IDs across different systems - where it wouldn’t be possible to track using an auto incrementing integer.
Redis: Connect, Set & Get in Go
Redis is a in-memory data store, used a lot in the backend systems of web-apps. Specifically, it’s good at helping with caching and message as it’s high performance lends itself to fast response times at retriving data.
In this blog post, we will demonstrate how to connect to Redis using Go and the go-redis library, which is one of the most popular and widely-used libraries for interacting with Redis in Go.
Organizing Structs for Memory Efficiency
Go is generally a very memory efficient language to work in, but knowing this little technique can make it that bit more efficient again.
First, we’ll look at structs - they are a composite data type used to group together zero or more values, each with its own name and type, under a single name. They are the foundation for building complex data structures and objects.
Memory alignment is an essential aspect to consider when organizing structs in Go.