I’m half way through my 30 days of code, it wont all be contiguous but I hope the 30 day sprint will get me much further forward with go. Then it will be back to a day a week of gophering.
My third week of gophering suggests that if you don’t know about interfaces then you are screwed. You can get by without them but all the cool kids are using them, and documentation being what it is; BAD I mean, without being able to investigate the package code directly you only hope is to code without reuse. If others are using interfaces everywhere then you’d better be able to recognise what is going on.
After trying, and failing, to a large extent to wrestle with json I decided I needed to know, and the best outline I could find was:
Further, I still struggling with json. Not getting it to do stuff, but to do stuff in a more efficient way than I’ve coded it.
Say encoding json to a file – no problem as you’d expect, but decoding it! All I want to do is run through each record looking for the last then grab its ID. But it seems I have to pull in all the records waiting until I hit EOF and then grad that last ID. My code is filled with comments saying ‘it works but surely this can’t be right, comeback and fix it when you know more!’
Gets the job done but it just isn’t pretty! I expect there is a pesky interface I don’t understand. I imagine I could file seek one record back from the EOF but that requires me to know how many bytes the last encoded json record has – how the hell do I know that!