Created
July 16, 2018 09:29
-
-
Save ramadani/f0bb2de3b63ca3fb5ed42194865bafaa to your computer and use it in GitHub Desktop.
Circle Package Example with Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package circle | |
import ( | |
"math" | |
) | |
type Circle struct { | |
Radius float64 | |
} | |
func (c Circle) Diameter() float64 { | |
return 2 * c.Radius | |
} | |
func (c Circle) Area() float64 { | |
return math.Pi * c.Radius * c.Radius | |
} | |
func (c Circle) Circumference() float64 { | |
return math.Pi * c.Diameter() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment