简体   繁体   中英

Is it possible to convert struct to ant.Any type?

type state struct{
    name string    
    zipcode string  
}

I want to convert this to any.Any type, plzz help!

If I understood correctly, you're trying to convert to the any which is an alias to interface{} .

You can do

y := interface{}(x)

z := any(x)

But I'm curious why you need this, maybe you're having a XY Problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM