Closed zhenweiwang1990 closed 11 years ago
That's because you do hd.CreateTable(&Fruit{})
instead of tx.CreateTable(&Fruit{})
I guess the real question is why does the example in the README use hd.CreateTable(&Fruit{})
outside of the transaction scope? Is that no longer correct?
When the table is created, no transaction has been started. Where do you see a declaration of tx
before hd.CreateTable
?
It isn't, and when the example is run, it fails with this error: panic: CreateTable can only be invoked inside a transaction
.
Oh, I see. Must be a relic of the past.
I have move the CreateTable calling behind the
tx := hd.Begin()
,I still get an error