如何使用“放入”到RunInTransaction中来获取密钥,而无需等到交易之后

The structure for a database I´m building its like a chain, it looks like this: Click here to see the structure enter image description here

Where those parts are: Click here to see what represents each part enter image description here

So, when I want to add new data to my chain: Click here to see the new data coming enter image description here,in any place I want, I can just easily update their values by updating the datastore.key of the structs: click here to see the update enter image description here

So, in this case I just need to update b.NextBlock, c.LastBlock, e.LastBlock and e.NextBlock and everything its fine, but lets supposed I want to add more new data Click her to see new data coming enter image description hereand I don´t want to save the chain if any of that data fail ¿what should I do?

So, the normal thing to think in both cases it's to do it with "client.RunInTransaction" method for each new data so I guarantee that everything was fine,but this its not possible because I can´t get the "datastore.key" when appending data to datastore into "client.RunInTransaction" as documentation says https://godoc.org/cloud.google.com/go/datastore#Transaction.Put (it returns *PendingKey no key itself) and I need to be outside "client.RunInTransaction" in order to get the "datastore.key" of the element and "commit" as documentation says https://godoc.org/cloud.google.com/go/datastore#Commit.Key

So, I want the funtion "put" into "client.RunInTransaction" give me the key of that element when the code is inside "client.RunInTransaction", no after, so I can guarantee that everything was ok with the update, because if I have the key after, the next appending may fail and I don´t want my data to save it

First create the new data entity separately, to get its key. The LastBlock and NextBlock properties would still be empty at this point.

Only after you have the entity's key use the transaction to perform the entity's insertion in the list, in which you only update the key references for that entity as well as the previous and the next entities (if any) in between which the entity is to be inserted.