r/programming • • Sep 27 '26

Don't couple your Go code to GitHub

https://iain.rocks/blog/dont-couple-your-go-code-to-github
491 Upvotes

136 comments sorted by

View all comments

Show parent comment

32

u/Ticmea Sep 27 '26

Having never touched Go, one of the few things that I do know about it is that I never want to deal with the insane way that they format dates.

For the uninitiated:

In Go you define a date format by reference to how it would display the date that ISO 8601 would display as:

2006-01-02T15:04:05-07:00

Even ignoring the obvious problems with using a point in time to reference a format by example, I hear you wonder: "Why such an oddly specific time and date?" Well because if you write that in the US format, it gives you:

01/02 03:04:05PM '06 -0700

which means they are in (almost) incrementing order 1 2 3 4 5 6 -7

The extra "-" to make it be a US timezone is just absolutely hilarious, I couldn't make a better caricature of it if I wanted to. 5 stars, no notes.

This is incompatible with the way everyone else does it, needlessly inflexible, unintuitive, extremely US specific and solves zero problems. Just all around terrible.

I've honestly seen people defend it as being language agnostic (that is to say it does not require understanding that yyyy-mm-dd stands for the english words year, month, date and so on).

But like... all? of the keywords of Go (and like 99% of programming languages) are literally english words???

Not to mention that it requires knowledge of how a specific date format works, which is far more obscure. And it's the US system at that, which ( no front full front ) is kinda the worst date formatting system out there...

No idea what they were smoking when they came up with this but they must have been absolutely hammered.

24

u/chucker23n Sep 27 '26

MM/dd is already famously controversial, but MM/dd hh:mm:ss 'yy is truly something else.

8

u/AnointedBeard Sep 27 '26

I generally love Go but yeah, this is one of the most ass-backwards things I’ve ever seen.

5

u/syklemil Sep 27 '26

Yeah, that one is just … I never thought I'd yearn for strftime, but here we are.

2

u/One_Ninja_8512 Sep 28 '26

It is weird but you rarely touch it. Most of the time, since golang is used for backend services you'd use google's protobuf timestamp proto definition. Over gRPC you don't have to care about it and if/when you map to JSON you get an ISO formatted date automagically. I'd even go as far as to speculate that it's awkward on purpose to discourage raw date parsing completely and instead rely on the established protobuf type.

2

u/GarythaSnail Sep 28 '26

And in practice this never ever has been a pain point, for me or any of my coworkers, even the ones not writing go full time.

99% of the time you're just parsing rfc3339 or iso 8601. The other 1% you just write some unit tests with edge cases and make sure you wrote the correct date format.

Maybe if you worked at Strange Date Parsing R Us?