This commit is contained in:
a.pivkin
2025-07-16 08:15:26 +03:00
parent cebbf27b3a
commit 0635aaa5ae
53 changed files with 76 additions and 4 deletions
+3
View File
@@ -0,0 +1,3 @@
module main.go
go 1.24.4
+37
View File
@@ -0,0 +1,37 @@
package main
import "fmt"
type Student struct {
name string
age int
}
type Desriber interface {
Describe()
}
func (std Student) Describe(){
fmt.Printf("%s and %d y.o",std.name,std.age)
}
func TypeDescriber(i interface{}){
switch v := i.(type){
case string:
fmt.Println("I am string")
case int:
fmt.Println("I am int")
case Desriber:
fmt.Println("I am describer!")
v.Describe()
default:
fmt.Println("Unknown type but I still work!")
}
}
func main() {
TypeDescriber(9)
std := Student{"Alex", 19}
TypeDescriber(std)
}