8 ms·
> But that doesn't stop you from declaring a var s Struct, and never initializing it, or making a NewStruct {}. Static analysis tools can catch this, no?
by olmo23 1mo ago
> But that doesn't stop you from declaring a var s Struct, and never initializing it, or making a NewStruct {}.
Static analysis tools can catch this, no?
- majewsky 1mo agoStatic analysis does not help if the type comes from a library and is _meant_ to be initialized using a literal. And then upstream adds new fields where the zero value is different from the previous behavior, causing users to silently drift away from the intended behavior. I had this happen to me with a type from std, and had to add a specific test to guard against it with future std upgrades: https://github.com/sapcc/go-bits/pull/309/changes#diff-f5721003d3d035743b2ce1e71dd06f777cd568229ee191e46d5eac5f52532732R35-R52 https://github.com/sapcc/go-bits/pull/309/changes#diff-f5721...
- duckbrain 1mo agoThat's a dependency making a breaking change, right?