Example #1
0
File: cf.go Project: tosmi/golang
func main() {
	for _, arg := range os.Args[1:] {
		t, err := strconv.ParseFloat(arg, 64)
		if err != nil {
			fmt.Fprintf(os.Stderr, "cf: %v\n", err)
			os.Exit(1)
		}
		f := tempconv.Fahrenheit(t)
		c := tempconv.Celcius(t)
		fmt.Printf("%s = %s, %s = %s\n", f, tempconv.FtoC(f), c, tempconv.CtoF(c))
	}
}
Example #2
0
func main() {
	for _, arg := range os.Args[1:] {
		t, err := strconv.ParseFloat(arg, 64)
		if err != nil {
			fmt.Fprintf(os.Stderr, "convert: %v\n", err)
			os.Exit(1)
		}
		f := tempconv.Fahrenheit(t)
		c := tempconv.Celcius(t)
		ke := tempconv.Kelvin(t)
		k := weightconv.Kilogram(t)
		p := weightconv.Pounds(t)

		fmt.Printf("%s = %s, %s = %s, %s = %s, %s = %s, %s = %s\n",
			f, tempconv.FtoC(f),
			c, tempconv.CtoF(c),
			ke, tempconv.KtoC(ke),
			k, weightconv.KtoP(k),
			p, weightconv.PtoK(p),
		)
	}
}