August 2019
Beginner to intermediate
798 pages
17h 2m
English
In this subsection, you will learn how to use the switch statement to differentiate between different data types using the Go code of switch.go, which will be presented in four parts. The Go code of switch.go is partially based on useInterface.go, but it will add another type named rectangle and will not need to implement the methods of any interface.
The first part of the program is next:
package main
import (
"fmt"
)
As the code in switch.go will not work with the interface defined in myInterface.go, there is no need to import the myInterface package.
The second part is where you define the three new data types that will be used in the program:
type square struct { X float64 } type circle struct ...Read now
Unlock full access