Golang

Sponsored links
Golang

Golang Don’t pass a value to a callback in a loop with range

If a value is passed to a callback in a loop with range keyword, it can introduce a bug. The desired value is not used in the callback if it is triggered later. You should know how to work range keyword in this post.
Golang

Golang How to extract the desired data from a string by regex

How can we implement it to extract values from a string? Using a regular expression is the right approach for it. Compile regex string and find string submatch.
Golang

Golang How to define enum and understand how iota works

What is the best practice to define enum in Golang? Use iota for enum and define String() func.
Golang

Golang How to check if key exists in map

How to initialize map There are two ways to initialize map in Golang. Initialization without any key-value If it's not n...
Golang

Golang How to convert string to float, int

Do you want a cheat sheet to know how to convert value to another data type? This article covers what you want.
Golang

Golang Improper package structure exports unneeded members

Do you want to write unit tests for methods but don't want to expose them to outside of the package? Then, move the methods to internal package. The functions defined in internal package are not exposed. Let's learn how to use it.
Golang

Golang How to mock an object by yourself for unit testing

It might be too big to introduce a mock framework. It's better to create a mock object by ourselves in this case.
Golang

Golang How to accept an arbitrary number of arguments

Are you searching for a way to accept an arbitrary number of parameters? Can the parameters have mixed data types? Then, this post is for you. Let's handle the parameter depending on the type.
Golang

Golang How to get value from any/interface

If a function has a parameter that is any or interface{}, it's not possible to access a property by a dot chain. How can we read a value in this case?
Golang

Golang How to differentiate between Context cancel and timeout

This post explains how to use Context for the process cancellation or timeout. Furthermore, it shows you how to implement it if you want to keep the process but want to introduce Timeout in it.
Sponsored links