In a nutshell basically you need to test the code you write to ensure you’re doing it right. If you have a function that add two numbers, you will expect the result to be sum of those two numbers, by writing the unit test, you make sure that when the function is being ran with the given parameters, it will return the correct / expected result or behavior.
This writing will cover up only the basic of golang unit testing with some example and explanation, more advance and complex unit testing / even mocking a function will be covered in…
Have you ever heard of closure before?
Ups different closure…
By Tour of Go definition, closure can be described as
Go functions may be closures. A closure is a function value that references variables from outside its body. The function may access and assign to the referenced variables; in this sense the function is “bound” to the variables.
I modified the code a bit from the Tour of Go example:
We’re going to create a simple API doc with the help of https://github.com/swaggo/swag library. It supports several golang framework such as gin, echo, fiber, flamingo, net/http, etc. In a nutshell you need to install it first (for generating via CLI), write some comments metadata in your API / handler / controller, generate and done!
First let us create some simple API using gin framework. We’re initiating an API group of “/api/v1/user” in which consists of two endpoint
If you’re having a public endpoint, securing it is a must and cannot be considered as nice to have. I would like to share several ways to secure your API Endpoint (Golang will be used for this example), and in this writing we won’t be discussing about any encryption related topic for simplicity. There are some ways to secure your API endpoint using these methods:
What on earth is this writting? This tutorial will demonstrate a simple golang API for uploading file to Google Cloud Storage. GCS (Google Cloud Storage) can be used for uploading your image, files, assets, basically any file with the benefits of
Some of you might already heard about a lot of caching out there, Redis and Memcached probably the common things when we’re talking about caching. However, in this writing I would like to show you a comparison of a simple API performance, in which the data is being stored on database (postgres), redis, and go-cache.
Redis as stated in the official website documentation (https://redis.io/).
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker. Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs…
For those of you who haven’t heard, bulk processing in a nutshell can be described more or less of a small multiple processes that is being ran at one single process rather than individually. In this writing, I’m about to show you one simple case in which bulk query to database can enhance performance compared to doing several queries one after another.
There are a few process in this example that we will run through:
Monitoring your application performance is an important subject that must be put in mind when we have our application running in Production. This kind of monitoring helps us to be aware if there is a slow down or performance issue within our system. Without any performance monitoring, it is hard for us to pin point which process takes longer to finish.
There are a lot of APM services out there, but let us try one open source elastic APM with golang this time. This writing will be focus on:
I had my wonderful time working at Tokopedia for three years starting at 2017 until 2020. Started as a Software Engineer, then Senior SE, and ended up as a Software Engineer Lead taught me a lot of lesson and experience. I met with a lot of great people, friends, and great leaders that directly or indirectly shaped me of who I am right now. As I’m currently starting new Journey in different place and culture, here are some precious highlight that I learned in Tokopedia as an Engineer.
Fellow Software Engineer