mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 13:03:39 +00:00
Add rudimentary interface support
This commit is contained in:
@@ -22,12 +22,25 @@ func main() {
|
||||
|
||||
thing := Thing{"foo"}
|
||||
println("thing:", thing.String())
|
||||
printItf(5)
|
||||
printItf(byte('x'))
|
||||
}
|
||||
|
||||
func strlen(s string) int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
func printItf(val interface{}) {
|
||||
switch val := val.(type) {
|
||||
case int:
|
||||
println("is int:", val)
|
||||
case byte:
|
||||
println("is byte:", val)
|
||||
default:
|
||||
println("is ?")
|
||||
}
|
||||
}
|
||||
|
||||
func calculateAnswer() int {
|
||||
seven := 7
|
||||
return SIX * seven
|
||||
|
||||
@@ -26,6 +26,10 @@ void __go_printint(intgo_t n) {
|
||||
putchar((n % 10) + '0');
|
||||
}
|
||||
|
||||
void __go_printbyte(uint8_t c) {
|
||||
putchar(c);
|
||||
}
|
||||
|
||||
void __go_printspace() {
|
||||
putchar(' ');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user