I often pass a struct to a function, sometimes the structs contain pointers,
then on initialisation, the question is how to do it in the simplest possible way?
The definition of transactionType is string
purchaseRequest(&merchant.MerchantPurchaseRequest{
TransactionType: &"21", // <-- want to do this
})
// but have to do this
txT := merchant.TransactionType("21")
purchaseRequest(&merchant.MerchantPurchaseRequest{
TransactionType: &txT,
})
https://golang.org/ref/spec#Address_operators
No comments:
Post a Comment