Skip to content

Instantly share code, notes, and snippets.

@chardos
Last active February 6, 2019 09:03
Show Gist options
  • Save chardos/1b63ec6aae1830a80907d347a3c1125e to your computer and use it in GitHub Desktop.
Save chardos/1b63ec6aae1830a80907d347a3c1125e to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Rect struct {
width int
height int
}
func (r *Rect) PrintArea() string {
area := fmt.Sprintf("Area: %d", (r.width * r.height))
return area
}
func main() {
rect := Rect{10, 20}
fmt.Println(rect)
fmt.Println(rect.width)
fmt.Println(rect.PrintArea())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment