Re:Go Is a Well-Designed Language
by nijave on Friday January 31, 2025 @02:14PM
(#42890712)
Maybe I'm missing something obvious but that seemed to be the only option for injecting stub implementations in integration tests.
[ Parent
| on HN ]
Re:Go Is a Well-Designed Language
by mikeschinkel on Saturday February 01, 2025 @12:56AM
(#42896059)
Interfaces are one way to inject stubs, and a good way, but not the only way. You can also use function values as callbacks.
Re:Go Is a Well-Designed Language
by roncesvalles on Saturday February 01, 2025 @04:44AM
(#42897194)
I prefer the testing libraries that do monkey-patching and consider mock implementations of interfaces to be an antipattern in Go, especially if it's the only reason for putting an interface between the calling code and a type.