I think reflection was used here because 'tool' wasn't available until Init had been run. Instead, the NewClient invocation is hoisted to the global variable definition, and the reflection becomes unnecessary.
Furthermore, the clientImpl was being passed around by value quite a lot, and therefore copied. Copies were being taken of its state before loadAuth was called, resulting in requests lacking a token. Instead, we now only have one global clientImpl, which is constructed at variable initialisation time.
The motivation for this is to complete the rename of 'test' to 'simulation': gorename can't see through the reflection.
I think reflection was used here because 'tool' wasn't available until Init had been run. Instead, the
NewClient
invocation is hoisted to the global variable definition, and the reflection becomes unnecessary.Furthermore, the
clientImpl
was being passed around by value quite a lot, and therefore copied. Copies were being taken of its state beforeloadAuth
was called, resulting in requests lacking a token. Instead, we now only have one globalclientImpl
, which is constructed at variable initialisation time.The motivation for this is to complete the rename of 'test' to 'simulation': gorename can't see through the reflection.