Thursday 2 July 2020

Golang quirks

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 
https://stackoverflow.com/questions/30716354/how-do-i-do-a-literal-int64-in-go/30716481

Chipmaster Gear Cutting

  Calculate all the possible gear combinations for the gear selector to cut a 15TPI thread: Imperial TPI C 5 24 20 Imperial TPI ...