Would I be correct in understanding that you want to avoid having a domainReg instance with uninitialized values? If so, yes, I believe this is a valid implementation. The vast majority of the packages that I've seen or used have some variety of your custom_subdomain.NewDomainRegistration() function. They allow you to control how things get initialized, which is not possible with plain-old struct instance construction.
Sweet! I felt the same initially. It's almost like one of those "when in Rome" situations. I will say, it's quite nice when you decide you want to mock internal functions in unit tests. Then you only have to build upon the initialization function, like any other new feature, rather than having to adopt it much later.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Would I be correct in understanding that you want to avoid having a
domainReg
instance with uninitialized values? If so, yes, I believe this is a valid implementation. The vast majority of the packages that I've seen or used have some variety of yourcustom_subdomain.NewDomainRegistration()
function. They allow you to control how things get initialized, which is not possible with plain-old struct instance construction.Please correct me, if I'm misreading. :)
Awesome! Yeah that's exactly what I want to do.
For some reason it didn't feel very "go"
Sweet! I felt the same initially. It's almost like one of those "when in Rome" situations. I will say, it's quite nice when you decide you want to mock internal functions in unit tests. Then you only have to build upon the initialization function, like any other new feature, rather than having to adopt it much later.