Go – x.(T) Type Assertions

An interface variable can store any non-interface concrete value, which is really useful when you are not sure about your variable type.

Because interface variable can be any kind of concrete value, we need a good way to determine the REAL value type of interface variable is to use Type Assertions from Go.
Continue reading


Go – append/prepend item into slice

In Go, you can use append to insert the item into slice.

func append

func append(slice []Type, elems ...Type) []Type

append(sliceA, sliceB) function will append sliceB to sliceA and return a new slice, which means you can decide prepend/append by changing these two parameters.
Continue reading