take the sine of a number in go

To take the sine of a number in Go, you first need to import the math package which contains the Sin function. Then, you can simply call the Sin function, passing in the number you want to take the sine of as an argument. Here's an example:

main.go
package main

import (
    "fmt"
    "math"
)

func main() {
    num := 0.5
    sin := math.Sin(num)
    fmt.Printf("The sine of %f is %f\n", num, sin)
}
154 chars
13 lines

In this example, we're taking the sine of the number 0.5 and storing the result in the variable sin. We then print out the result using fmt.Printf. The output of this program would be:

main.go
The sine of 0.500000 is 0.479426
33 chars
2 lines

gistlibby LogSnag