30秒学会 Golang 片段 – Degrees
Converts an angle from radians to degrees.
Use math.Pi
and the radian to degree formula to convert the angle from radians to degrees.
代码实现
import "math"
func Degrees(r float64) float64 {
return r * 180.0 / math.Pi
}
使用样例
Degrees(math.Pi / 2.0) // 90.0