The Age of Go

Report a typo

The Go language was announced in 2009. Create an interface age with the age of the Go language. Suppose today the year is 2022, then the age would be 13.

After creating the interface, print out the data type of the interface's value:

  • If the type is nil, then print Age is nil type.
  • If the type is int, print Age is int type.
  • If the type is string, print Age is string type.
  • In all other cases print Type is not defined.

Sample Input 1:

Sample Output 1:

Age is int type
Write a program in Go
package main

import "fmt"

func main() {
var age interface{} = 13
switch age.(type) {
case ???:
//put your code here
case ???:
//put your code here
case ???:
//put your code here
default:
//put your code here
}
}
___

Create a free account to access the full topic