Published Jun 21, 2023
Contribute to Docs

The Sin() function in Go is used to calculate the sine of an angle. It returns the sine value of the specified angle given in radians.


The syntax for using the Sin() function in Go is as follows:

import "math"

result := math.Sin(angle)

Where result is the sine of angle.


The following example demonstrates a basic implementation of the Sin() function:

package main
import (
func main() {
angle := 45.0
sineValue := math.Sin(angle * math.Pi / 180) // Convert 45(in degrees) to radians
fmt.Println("Sine of", angle, "degrees is", sineValue)

This code will print the following output:

Sine of 45 degrees is 0.70710678118

All contributors

Looking to contribute?

Learn Go on Codecademy