golang提问一下关于类型转换的问题(谢谢,一直没看懂)

98 阅读1分钟
type celsius float64
type kelvin float64
type fahrenheit float64
func celsiusToKelvin(c celsius) kelvin{
	return kelvin(c + 273.15)
}
func celsiusToFahrenheit(c celsius) fahrenheit{
	return fahrenheit(c * 33.8)
}
func kelvinToCelsius(k kelvin) celsius{
	return celsius(k - 273.15)
}
func kelvinToFahrenheit(k kelvin) fahrenheit{
	return fahrenheit(9 * (k-273.15)/5 + 32)
}
func fahrenheitToCelsius(f fahrenheit) celsius{
	return celsius(f - 273.15)
}
func fahrenheitToKelvin(f fahrenheit) kelvin{
	return kelvin(9 * (f-273.15)/5 + 32)
}

func main() {
	var choose string
	var x float32
	fmt.Println("请选择需要转换的温度类型:\n 1.摄氏度转换\n 2.开尔文温度转换\n 3.华氏度转换")
	fmt.Scanf("%v",&choose)
	switch choose{
	case "1":
		fmt.Scanf("%f",&x)
		k := celsiusToKelvin(x)
		f := celsiusToFahrenheit(x)
	    fmt.Print(x,"摄氏度,为",k,"开尔文度数,为",f,"华氏度")
	case "2":
		fmt.Scanf("%f",&x)
		c := kelvinToCelsius(x)
		f := kelvinToFahrenheit(x)
	    fmt.Print(x,"华氏度,为",c,"摄氏度数,为",f,"华氏度")
	}
	
	
}

报错为 cannot use x (variable of type float32) as type celsius in argument to celsiusToKelvin

image.png