3 ms·
Cool but all you really needed to do was fix the contract between NewActionDeleteObject’s struct creation and the switch statements result = print. What’s reall
by reactordev 2y ago
Cool but all you really needed to do was fix the contract between NewActionDeleteObject’s struct creation and the switch statements result = print. What’s really crazy is you can create anonymous structs to unmarshal json without having to fully flesh out data models thanks to its “we’ll only map the fields we see in the struct” approach. Mapstructure takes this even further with squash. In the end, the type checker missed the error because it was user error by contract and that, due to lack of validation that the actions were constructed properly, resulted in a rabbit hole debugging session that ended with an excellent blog post about the gotchas of unmarshaling.
- hinkley 2y ago> human error Humans suck at formalisms. When XML was the 'sane choice' I grew to hate it, until I met a person who introduced me to XMLSpy. It has a mode where instead of trying to define the schema you offer it example documents and it offers you a schema that seems to satisfy your examples, at which point you can either switch to manual or provide more examples. He was right, it did make me hate XML a lot less. At least until the next job when they wouldn't pay for it.