Golang string to int

02 January, 2017

The built in 'strconv' package contains a function named 'Atoi' (ASCII to integer). Which is just a wrapper for the 'ParseInt' function.

PHP milliseconds timestamp as an integer

05 June, 2016

There is no native function for a unix timestamp in milliseconds, only 'time()' which returns seconds since epoch and 'microtime()', which returns microseconds since the current second. Although you can use 'microtime(true)', but it returns a float that can not guarantee precision. Or just 'microtime()' and explode the string.

Golang byte to int example

10 May, 2016

In Golang there isn't a native function to convert a character number (!= int number) to int.

An int in bytes is the normal sequence of 0-9 normally, but when you are dealing with number characters, they start of at number 48 (in the ASCII table)

So a character 0 is 48 in bytes, 1 is 49, 2 is 50, and so on...

Home