1
0
mirror of https://github.com/MADTeacher/go_basics.git synced 2025-11-23 21:34:47 +02:00
Files
go_basics/part_3/3.9/3.go

21 lines
338 B
Go
Raw Normal View History

package main
import "fmt"
type shape struct {
name string
}
func (s *shape) getName() string {
return s.name
}
func main() {
var firstInterface interface{} = shape{name: "Cube"}
var secondInterface interface{} = "Oo"
fmt.Printf("%+v\n", secondInterface.(string)) // ok
fmt.Printf("%+v\n", firstInterface.(string)) // error
}