Go Coding Practice
Practice typing real code syntax, including brackets, punctuation, and indentation. Snippets are for typing practice only and are never executed.
Structs and methods
Type the code exactly. Tab inserts four spaces. Code is not executed.
Progress: 0%
Current mismatches: 0
package main
import "fmt"
type Rectangle struct {
width float64
height float64
}
func (r Rectangle) Area() float64 {
return r.width * r.height
}
func main() {
shape := Rectangle{width: 6, height: 4}
fmt.Printf("Area: %.1f\n", shape.Area())
}
Type the code exactly, including spaces and indentation.