IT-개발,DB

go lang convert struct to interface{}

SB리치퍼슨 2021. 8. 31. 19:54

go lang convert struct to interface{}

p := Person{"John", 21}
var v interface{} 
v = p


go lang convert interface{} to struct

type Person struct {
	name string
    age	 uint
}

func convToStruct(v interface{}) Person {
  p := v.(Person)
  
  return p
}

 




반응형