# Golang Program to Create a Class and Compute the Area and Perimeter of a Circle

Go ProgrammingServer Side ProgrammingProgramming

To compute the area and perimeter of a circle, we can take following steps −

• Define a struct with circle properties such as radius.
• Define a method to calculate the area of the circle.
• Define a method to calculate the perimeter of the circle.
• In the main method, take the user's input for circle's radius.
• Instantiate the circle with the radius.
• Print the area of the circle.
• Print the perimeter of the circle.

## Example

Live Demo

package main
import (
"fmt"
"math"
)
type Circle struct {
}
func (r *Circle)Area() float64{
}
func (r *Circle)Perimeter() float64{
return 2 * math.Pi * r.radius
}
func main(){
fmt.Printf("Enter radius of the circle: ")
}
Enter radius of the circle: 7
Perimeter of the circle is: 43.98