1
我想知道是否有可能通過動態結構作爲函數的參數?動態結構作爲參數Golang
type ReturnValue struct {
Status string
CustomStruct // here should store any struct given
}
func GetReturn(status string, class interface{}){
var result = ReturnValue {Status : status, CustomStruct : //here any struct should be stored}
fmt.Prinln(result)
}
type Message1 struct {
message : string
}
func main(){
var message = Message1 {message: "Hello"}
GetReturn("success", message)
}
https://play.golang.org/p/kV_k_-p4NH – mkopriva