Perfect. Le mardi 24 janvier 2017 14:42:57 UTC+1, Jordan Krage a écrit : > > As of Go 1.8, this should be easy. You can now convert between two > structs which differ only in tags (1.8 release notes > <https://tip.golang.org/doc/go1.8#language>), so you can have a separate > struct definition for each type (json, bson, gorm, strom, etc.). > > > On Tuesday, January 24, 2017 at 7:30:58 AM UTC-6, skat...@root.gg wrote: >> >> Hello, >> I'm looking for a way to split fields tags in multiple files. >> >> My application can work with different backends (mongodb / sql / storm) that >> could persist the same objects. Add json for the Rest API and the fields >> tags definitions start to be really ugly. >> >> type MyStruct struct { >> ID string `json:"id" bson:"id" gorm:"column:id;primary_key" >> storm:"unique"` >> Creation int64 `json:"uploadDate" bson:"uploadDate" >> gorm:"column:uploadDate" storm:"index"` >> TTL int `json:"ttl" bson:"ttl" gorm:"column:ttl"` >> ... >> } >> >> Backend code is splitted into modules and I'd like that each module >> define tags it needs. >> Does anyone sees a solution ? >> >
-- 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. For more options, visit https://groups.google.com/d/optout.