How to read a data in interface data type variable by Scan in golang while run a go file?

Viewed 21

simple demo code

  • declare a interface variable
  • insert data into it by scan of any method possible


package main

import (
    "fmt"
)

func main() {
    var s interface{}               
    fmt.Println("enter string")
    fmt.Scan(&s)                  
    fmt.Println(s)
}

Result now by this code

enter string
<nil>
0 Answers
Related