본문 바로가기
IT-개발,DB

go lang convert struct to interface{}

by SB리치퍼슨 2021. 8. 31.

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
}

 




반응형

댓글