The problem is that these types must be used by packages importing my package. I'm in doubt between declaring identical (but not compatible) types like in the sql package, or using type alias to have true identical types.
Thanks Manlio Perillo On Friday, February 22, 2019 at 3:26:03 AM UTC+1, DrGo wrote: > > what worked for me in a largish project is using an internal package > (named "types") to host types used in more than package. > > On Thursday, February 21, 2019 at 3:30:08 PM UTC-6, Manlio Perillo wrote: >> >> Hi. >> >> I'm implementing a generic (and very simple) interface for key-value >> databases, and I'm using the standard database/sql package as a reference. >> The only difference is that I don't plan to have a Driver interface, but >> only a Database and Tx interfaces. >> >> For starting a transaction I'm thinking of something like this: >> >> type TxMode int >> >> const ( >> ReadOnly TxMode iota >> ReadWrite >> ) >> >> func Begin(mode TxMode) (Tx, error) >> >> >> Now, that problem is that this type needs to be used by both the driver >> and the database packages. >> >> For the standard database/sql package, the TxOptions type is duplicated. >> Is there a reason for this duplication? >> I was thinking of declaring the TxMode in the driver package and using a >> type alias in the database package, but I'm not sure. >> >> >> Thanks >> Manlio Perillo >> > -- 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.