Golang : micron to centimeter example
Problem:
You need to convert centimeter to micron (µ) in Golang. How to do that?
Solution:
Simple. See the following code:
package main
import (
"fmt"
)
func micron2cm(µ float64) float64 {
return µ / 10000
}
func cm2micron(cm float64) float64 {
return cm * 10000
}
func main() {
fmt.Println("10 µ in centimeter is : ", micron2cm(10.0))
fmt.Println(micron2cm(10.0), " centimeter in µ :", cm2micron(micron2cm(10.0)))
}
Output:
10 µ in centimeter is : 0.001
0.001 centimeter in µ : 10
References:
http://www.allmeasures.com/Fullconversion.asp
https://socketloop.com/tutorials/golang-temperatures-conversion-example
See also : Golang : Temperatures conversion example
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+7.5k Golang : get the current working directory of a running program
+7.4k Golang : Error reading timestamp with GORM or SQL driver
+16.5k Golang : Set up source IP address before making HTTP request
+9.8k Golang : Get login name from environment and prompt for password
+22.7k Golang : Randomly pick an item from a slice/array example
+6.9k Golang : Fixing Gorilla mux http.FileServer() 404 problem
+7.3k Golang : Command line ticker to show work in progress
+11.6k Golang : Convert decimal number(integer) to IPv4 address
+23.9k Golang : How to validate URL the right way
+10.3k Golang : ISO8601 Duration Parser example
+13.1k Golang : Increment string example
+5.3k Golang : Stop goroutine without channel