Reading & Setting environment variables in Go
Posted on 📅 June 9, 2020
Use os.Getenv()
and os.Setenv()
for reading and setting environment variables.
🌗
Use os.Getenv()
and os.Setenv()
for reading and setting environment variables.
To find last modified file
find Documents/ -mtime -1
where mtime
means “Last Modification Time”
There are two ways I like (without any external dependency).
If you don’t know what next() in python means, the below code illustrates it.
To know who how long your go code executes you can use the time.Now()
and time.Since()
methods in the time
package.
vmstat -s | grep "total memory" | grep -Eo '[0-9]{1,}'
There are basically 2-3 methods to convert integer to string and back to integer but the most easiest way is to use the Itoa
and Atoi
methods in the strconv
package.
Splitting strings in Go is done by using the Split()
method.
You need to import the strings
standard library to use this.