Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
stpedgwdgfhgdd
on Feb 19, 2025
|
parent
|
context
|
favorite
| on:
One year after switching from Java to Go
I don't get the part on package. Often you want to use structs. (Instance vs static)
How would you construct an instance in a test that needs mock implementations?
roncesvalles
on Feb 19, 2025
[–]
Such an instance would just be a variable somewhere that would be initialized in some init() call when the program starts. Every user of that instance will use it directly (as opposed to storing a reference to it locally DI style).
gf000
on Feb 19, 2025
|
parent
[–]
So global mutable state? How wonderfully modern!
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
How would you construct an instance in a test that needs mock implementations?