I'm trying to retrieve the string value from a reflect.Value,
I expect value.String()
to be okok
but I got <interface {} Value>
instead.
Did I miss something?
package main
import (
"fmt"
"reflect"
)
func dump(args *[]interface{}) {
value := reflect.ValueOf(*args).Index(0)
fmt.Println(value.String())
if value.String() != "okok" {
fmt.Println("miss")
}
}
func main () {
var args []interface{}
args = append(args, "okok")
dump(&args)
}
Aucun commentaire:
Enregistrer un commentaire