Re: [go-nuts] Get struct type , save and reconstruct empty struct later

2019-07-20 Thread Vasiliy Tolstov
сб, 20 июл. 2019 г. в 17:17, Martin Schnabel :
>
> If you only need any unnamed struct type you can create one with reflect
> from the field information that you can write to text somewhere.
>
> https://godoc.org/reflect#StructOf
>
> These unnamed struct types however do not have any methods and do not
> wrap embedded named type methods.
>
> Otherwise you probably want to register your struct types on program
> initialization; for later lookup and so that they are part of the
> compiled binary. The gob package does it like that for example.
>

Thanks for link doc. It is very useful. Now i think that i'm try to
use protobuf Any (as all of my struct are protobuf proto.Message.
As i understand via protobuf i can register needed Req/Rsp empty
messages via Any, and later unmarshal message to this empty structs.


-- 
Vasiliy Tolstov,
e-mail: v.tols...@selfip.ru

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CACaajQtV_4DYtGpMZULc4TMEr8uTUZ2PaLbUHz54i2%3DnD6XVBw%40mail.gmail.com.


Re: [go-nuts] Get struct type , save and reconstruct empty struct later

2019-07-20 Thread Martin Schnabel

If you only need any unnamed struct type you can create one with reflect
from the field information that you can write to text somewhere.

https://godoc.org/reflect#StructOf

These unnamed struct types however do not have any methods and do not
wrap embedded named type methods.

Otherwise you probably want to register your struct types on program
initialization; for later lookup and so that they are part of the
compiled binary. The gob package does it like that for example.

Have fun!


On 20.07.19 10:44, Vasiliy Tolstov wrote:
Thanks, something like this, but i need to store type in string or 
[]byte in db, and based on this create new empty struct.


сб, 20 июл. 2019 г., 10:55 Jan Mercl <0xj...@gmail.com 
>:


On Sat, Jul 20, 2019 at 9:28 AM Vasiliy Tolstov mailto:v.tols...@selfip.ru>> wrote:

 > Hi. I have reflection based question.
 > I need to store type of struct passed to func and later based on
this stored type reconstruct empty needed struct.
 > Does this possible ?

Not sure I understood the question:
https://play.golang.org/p/5AEn3IsKObo

--
You received this message because you are subscribed to the Google 
Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to golang-nuts+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CACaajQsO90D5iDOZEpsgwbPBgEu%3DU8eLpYeg%3D2b2odAcp55f9g%40mail.gmail.com 
.


--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/df1d238c-4884-93a3-c5de-0fc56a3c928e%40mb0.org.


Re: [go-nuts] Get struct type , save and reconstruct empty struct later

2019-07-20 Thread Vasiliy Tolstov
Thanks, something like this, but i need to store type in string or []byte
in db, and based on this create new empty struct.

сб, 20 июл. 2019 г., 10:55 Jan Mercl <0xj...@gmail.com>:

> On Sat, Jul 20, 2019 at 9:28 AM Vasiliy Tolstov 
> wrote:
>
> > Hi. I have reflection based question.
> > I need to store type of struct passed to func and later based on this
> stored type reconstruct empty needed struct.
> > Does this possible ?
>
> Not sure I understood the question: https://play.golang.org/p/5AEn3IsKObo
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CACaajQsO90D5iDOZEpsgwbPBgEu%3DU8eLpYeg%3D2b2odAcp55f9g%40mail.gmail.com.


Re: [go-nuts] Get struct type , save and reconstruct empty struct later

2019-07-20 Thread Jan Mercl
On Sat, Jul 20, 2019 at 9:28 AM Vasiliy Tolstov  wrote:

> Hi. I have reflection based question.
> I need to store type of struct passed to func and later based on this stored 
> type reconstruct empty needed struct.
> Does this possible ?

Not sure I understood the question: https://play.golang.org/p/5AEn3IsKObo

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-XObyXZkDvMwouy52B9N-m8Rxi3PU-sPNRqJqycAXxq0w%40mail.gmail.com.


[go-nuts] Get struct type , save and reconstruct empty struct later

2019-07-20 Thread Vasiliy Tolstov
Hi. I have reflection based question.
I need to store type of struct passed to func and later based on this
stored type reconstruct empty needed struct.
Does this possible ?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CACaajQuvs1Ytv_67LUov420j-Aic2MtycS8BMC4HZ_kwNB%3DmAg%40mail.gmail.com.