Skip to content

Instantly share code, notes, and snippets.

@ramadani
Created July 16, 2018 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramadani/f0bb2de3b63ca3fb5ed42194865bafaa to your computer and use it in GitHub Desktop.
Save ramadani/f0bb2de3b63ca3fb5ed42194865bafaa to your computer and use it in GitHub Desktop.
Circle Package Example with Go
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