Episode Transcript
Available transcripts are automatically generated. Complete accuracy is not guaranteed.
Shay Nehmad (00:00):
This show is
supported by our beautiful
Patreon member. Wanna becomebeautiful yourself? Nah, you're
already beautiful. If you wannajoin Patreon, wait around till
the ad break to hear more aboutthat. This is a cup of go coming
(00:21):
to you from a literal coffeeshop for December 6, 2024.
Keep up to date with theimportant happenings in the Go
community in about 15 minutesper week. I'm Shay Nehmad. And
I'm Jonathan Hall. Which coffeeshop are you hailing from?
Jonathan Hall (00:37):
Yeah. I'm in,
Norm's. I think it's just called
Norms. Were they Norms? It'scalled Norms.
Yeah. Somebody had to confirmwith me in, downtown Newton,
Kansas.
Shay Nehmad (00:48):
How's the coffee?
You can only say it's really
good because they hear you.
Jonathan Hall (00:52):
It it is good.
Shay Nehmad (00:53):
John is, like,
holding the classic white,
stereo foam with, his cardboardthingy, cup. Looks beautiful. So
I hope it's full of go. We tookthe week off last week. A ton of
news this week.
So let's get started. Let'sstart with releases, then we
have a ton of proposals to jumpthrough. We'll talk about, like,
(01:16):
vetting a little bit andmultithreading a little bit. It
should be fun. And finally, Iwanna mention a a pretty fun
blog post I've, we've foundbecause someone sent it to us on
the Slack channel.
So let's get started. It's theversion I've been waiting for.
Jonathan Hall (01:29):
Yes. Finally, 1,
2, 3, 4 is here. There are only
40, 41 more minor releases to gountil we have 1, 2, 3, 4, 5. So
there's no, really interestingthings in 1, 2, 3, 4. No
security vulnerabilities thatare fixed or anything like that.
(01:51):
It's kinda just a run of themill release, but you should
upgrade. I did this morning.
Shay Nehmad (01:56):
Yeah. If it like,
mostly bug fixes. Right? Yep.
Run of the mill upgrade, justremember to do that.
That's I have an update on apast news item. It's not very
important. Do you know what gotest minus minus count does?
Jonathan Hall (02:13):
Not really. I
know that it is useful when you
want to disable the test cache.
Shay Nehmad (02:18):
So what it actually
does, it if you add, like, 3, it
will run the test 3 times. So ifyou wanna run the tests Okay.
Multiple times because maybe youwanna make sure that they are
isolated and you can run them afew times, that's pretty good.
Another flag that helps withthat is shuffle. Right?
You change the order every time,in that way you can find bugs,
(02:40):
yeah, that are caused by testsnot being isolated. Just like as
a side note, there are thingsyou can do other than running
shuffle and count to detecttests that are not isolated.
I've been working a lot aboutit, recently. One thing is
before and after each test, takea snapshot of all environment
variables. We I've been workingon it, with someone from my
(03:01):
team.
Look at accesses to databases,blah blah blah. A lot of things
you can do to make sure thetests are isolated and not
flaky, which we all like.Anyway, what do you think should
happen when you run minus, minuscount 3 and shuffle?
Jonathan Hall (03:18):
What I think
should happen is I it's a good
question. I don't know.
Shay Nehmad (03:22):
It's a bit tricky.
Right? So the way it worked so
far, you shuffled it and thenyou duplicated it, which
actually meant you didn't getthe effect I think most people
wanted, which is to double themfirst and then shuffle. So the
order is quote unquote morerandom. Right?
Jonathan Hall (03:38):
Mhmm.
Shay Nehmad (03:38):
That has been
discussed at infinitum in the
thread, what do we actually wantand whether the current
implementation is a bug or afeature. They decided it's a
bug, let's improve it. Let's do,like, the duplication first and
then just shuffling so it's moreshuffled. We updated on it and
there's a change list. Theyimplemented it and I did some
(03:59):
code review on it, which wasreally nice because I I think I
found some useful things.
That was, like, a few a whileago. And like every good change
list, it had some extra thingsin it. For example, updating the
version of math, which isinteresting because there's a
new there's math v 2. Right?
Jonathan Hall (04:17):
Math brand v 2?
Shay Nehmad (04:18):
Specifically. Yeah.
So they upgraded the version of
that as well, and, yeah. It'sit's still being worked on, but
looks like all the reviewersgave the thumbs up, and it's
gonna get implemented, I hope,really really soon.
Jonathan Hall (04:34):
Yeah. That's
really cool. How often do you
actually run with count otherthan 1?
Shay Nehmad (04:38):
On every CI, of
course. Because I want to catch
these cases. Okay. Just notnecessarily on every CI run,
maybe, like we do it on anightly basis just because it
costs a lot of CI time and it'srather expensive. So we do it on
a nightly basis instead.
And, yeah, it detects a lot offlakiness. It's a good method to
(04:59):
to do. You don't need a lot ofcount. You can do count 2 and
that probably takes care of allthe tests that change something
that will make the like, I can'tthink of a lot of cases where if
you run a test twice, it willpass, but thrice it will not.
You know what I mean?
Like, the big jump is from 1 to2. So, yeah, it's, there's a
change list and I did some codereview. It's really nice. You
(05:21):
should try to do that as wellsometimes, especially if the
change is about something youcare about like this one.
Jonathan Hall (05:27):
Yeah. Cool.
Shay Nehmad (05:28):
So we can talk
about the new proposals or we
can talk about 124. We'vedecided to not talk about 124,
the draft that's being draftedright now. Right?
Jonathan Hall (05:38):
Yeah. We'll have
plenty of time to talk about
that before February.
Shay Nehmad (05:41):
It's months out. We
think it's not relevant enough
yet, So we will talk about it.We know that the draft is out
there, but we wanna talk aboutproposals, first. Alright.
Jonathan Hall (05:52):
So the first one,
I wanna talk about is a new
proposal. This has not beenaccepted. It was just recently
added to the minutes. Although,the original proposal dates back
to 2016. So it's been around fora while.
The proposal is to add a new vetcheck to look for abuse of sync
wait group. If you're very usedto sync wait group, you probably
(06:12):
can imagine what we're talkingabout here. A common pattern
you'll see in the wild is tocall a goroutine. First thing
you do in the goroutine is youcall waitgroup.addone. And then
you call defer waitgroup.done.
This is wrong. And the reason isbecause your go routine may be
delayed in executing. The waitgroup may terminate before that
wg.add is even called. So youneed to call the wait group add
(06:34):
before you start the new goroutine. The proposal is to add
a vet check that will warn ifyou don't do that.
I think that's a great ideabecause this is such a simple
thing to do. It's a little brainfart issue that can it can bite
anybody, and, it's so easy todetect and warn us against it.
So I think it's a greatproposal.
Shay Nehmad (06:50):
How, ubiquitous is
this, like, quote unquote abuse?
Because if it never happens,maybe we shouldn't work on it.
Jonathan Hall (06:59):
Yeah. I don't
know how often it happens. I
know I have done it before. Idon't think I've done it often,
but I've definitely done itbefore. And Joe Tsai, who
brought up the issue, says thathe's seen it very commonly.
I don't know what that means. Idon't know what kind of research
he did to he doesn't providenumbers that I see about how
often it's done. Yeah. I don'tknow I don't know the answer. I
know I've done it before andhave and caught it because of a
(07:21):
bug, not because of a linter.
So I think a linter would begreat.
Shay Nehmad (07:25):
At the topic of,
linters, there's another new
proposal here. It's beenaccepted. It's not very new.
Like, it's been open since,2022, but it's been accepted
yesterday, and the final commentperiod went by without a hitch.
But it's it's new on my radarjust because a few weeks ago it
it popped up again.
(07:45):
In Go, we have struct tags.Right? So you can define a
struct with fields a, b, c of,like, string, int, int, and then
do JSON tags next to them. Writeback tick JSON something, that
sort of changed the JSONbehavior of that struct which is
super useful. One of these JSONtags is omit empty.
(08:07):
It's if the value is empty, omitit from the JSON. That's really
useful for example, if you'remarshalling an unmarshalling
JSON and you want to removefields that are empty when
you're writing them out becauseyou don't want to have all the
fields in their empty values.Especially useful since Go's 0
values are pretty unique. Like,
Jonathan Hall (08:28):
not a
Shay Nehmad (08:29):
lot of languages
represent Bool that isn't there
is false or a number that isn'tthere is 0. Most languages have
the concept of nil ability orsomething like that. So that
sort of provides a good way tointerrupt with a lot of the real
world. However, if you look atthe documentation for JSON,
(08:50):
marshalling in Go, whatever,omitempty is not as simple as it
is. Like if you're just workingwith simple values, you're just
working with ints, bools,whatever, maps, it's pretty it's
pretty obvious.
If the number is 0, you're gonnaemit it. However, time dot time
as a field, omit empty doesnothing because there's no
(09:13):
sensible, interpretation of omitempty on a struct field. This is
discussed within the proposal.It starts with time dot time and
then gets expanded to allstructs basically. You actually
have to work with pointer totime dot time because pointer is
a basic thing and you can youcan it can be nil.
(09:34):
Right? You can have a nilpointer and then if you get a
nil pointer, it's it can beomitted because it can be empty.
The proposals for vet to detectthis, like, weird situation and
just suggest, hey, you probablywanna use a pointer to time and
not just time. This getsdiscussed a lot whether we
should have something calledomit 0 and omit empty, etcetera,
etcetera. There's a lot ofresearch here about places where
(09:58):
this actually happens in the Gocode and how would that be,
affected.
There's a crazy number here that33% of omit empties are are
meaningless, which for me wasvery very funny. And someone
also here, I ran face first intothis very bug, Daniel Marti,
(10:18):
which we had on the show. I ranface first into this bug. I can
really feel, like, his pain.Anyway, this is, accepted, which
is very very I I think would bea great improvement to vet.
I'm wondering if this is aproblem with omit empty to begin
with. Like, how is this evenpossible. Right?
Jonathan Hall (10:40):
I I think it's
hard for me to say exactly. I
haven't been following the thenew JSON encoding proposals
really closely, But I know thatthis keeps coming up, the whole
issue about emit empty and emit0. It's it's just I mean, kind
of like you said before, it'sit's an ambiguity that different
languages handle different ways.And JSON is a it's not a Go
concept. So it it's where weit's sort of the border between
(11:02):
Go and the rest of the world.
So those ambiguities reallystart to shine in confusing ways
when we're trying to interopwith the rest of the world. So,
yeah, I don't know. I don'tthink there's a clean solution.
If there was, we probably wouldhave found it by now. There's
just a lot of ambiguity, and wehave to come up with the
solutions that the best in mostof the cases.
Shay Nehmad (11:21):
I think the the
problem is is Go is pretty
strictly defined. Like, youdon't get the quote unquote,
freedom of just like, yeah, I'mtrying to, to JSON load s
whatever Python object I loaded,it just works. Usually, you have
to be a bit more explicit thanthat, and the reason all these
(11:42):
things are kinda spiky and cancause bugs is because that
doesn't really gel well with Go,which is funny to say because
obviously Go is super good forweb work and whatever. But I
don't know. This is, obviously,I think a good, it's a great
improvement because 33% ofpeople are not gonna get this
(12:02):
this bug anymore, but I thinkpeople who are gonna get this
linter warning are gonna belike, wait, what?
This didn't work? But, you know,if they didn't notice it, maybe
it's not that important. Right?Maybe the the field has always
been passed.
Jonathan Hall (12:15):
Yeah. I I I can
see Stack Overflow exploding
with repeat questions of this.What does this error mean? Why
am I getting this?
Shay Nehmad (12:20):
Yeah. Actually, in
the original, post by, Josh
Bleakius Snyder, he's like, thisis a common source for package
JSON confusion, and it's alreadyspawned a handful of proposals.
Things like adding an omit 0option and no nil struct tag to
marshallnil slices and not null,and supporting 0 values of
struct with omit update likethis has been raised before.
(12:44):
It's been accepted now. It's Ithink it's actually been
mentioned in change lists aswell or someone already did like
an implementation.
So it might, join us prettysoon, which is pretty cool. Last
proposal on the docket.
Jonathan Hall (12:58):
Yeah. Let's
change gears here a little bit
and talk about somethingcompletely unrelated to vetting
and JSON. We have a newproposal, and this one might
sort of make your head explode alittle bit since we're talking
about Go, which is famous forits go routines and all that
stuff. But the proposal is toadd a new package called runtime
slash main thread that has asingle method in it or single
function in it called do. Mhmm.
(13:19):
And all do does is execute thecallback function you pass to
it. But it guarantees that it'sexecuted in the main go routine
or the main thread, I shouldsay. Why would you ever want
that? I can hear peoplethinking.
Shay Nehmad (13:32):
Like most Go
programs don't run on like
specific threads. Right? Thatdoesn't matter. I just have my
Go routines. They're greenthreads, whatever.
Jonathan Hall (13:39):
Yeah. Exactly.
But for, in particular, for
certain c Go programs or clibraries, some c libraries, are
required to run-in the mainthread. So this would be a way
to allow you to do that. Theproposal goes on to talk about
how there are better ways toaccomplish this.
Shay Nehmad (13:57):
If I'm running in a
goroutine, isn't that a green
thread? Doesn't it count as themain thread? Or does it actually
spawn like a different threadand then my c code won't work?
Jonathan Hall (14:07):
Yeah. I think it
definitely can do that, in in
certain circumstances. Yes. Itcan spawn a new a new thread and
then your c code won't work.
Shay Nehmad (14:14):
That's interesting.
I wonder what's like the c, code
that caused this thing to getimplemented. Right?
Jonathan Hall (14:22):
Yeah. Anyway,
it's a feature I might be using
just because I don't do or Idon't intend to be doing c go
code, but maybe I will at somepoint. But I can see how it very
much be, valuable if you aredoing that and and need that
that sort of control.
Shay Nehmad (14:36):
Yeah. Specifically,
things like find already did
that, like in their event loopin their main thread. They I
think they call, like, runtimedot lock OS thread when they in
it or things like that. Find theGUI library, which we talked
about a lot, seems to do thatalready.
Jonathan Hall (14:51):
Mhmm.
Shay Nehmad (14:52):
But I I really like
the the addition here of someone
suggesting, you know, you wannasince it can panic, do. If if Go
isn't in control of the mainthread, it might panic. So maybe
you wanna check if you can do itbefore you do it. So there's a
suggestion to add to the API,can do, which sounds very, like,
(15:13):
preppy. Right?
Can do Yes. Can do attitude. Butit would be a shame when it's,
when it returns false. This isthe, you know, the sorts of
proposals where, I like that wecan interrupt with other things,
in the real world. One timeJSON, one time c.
(15:34):
But just why can't everything bepure Go, and then we won't have
to like, the entire operatingsystem from top to bottom. Just
one big Go, binary. Why wouldn'tthat work, John?
Jonathan Hall (15:46):
I can't think of
any reason why that wouldn't
work. But that I'm going to talkabout.
Shay Nehmad (15:50):
New proposal.
Implement Windows in Go.
Jonathan Hall (15:55):
Cool. That would
solve a lot of the Windows
incompatibility problems,wouldn't it?
Shay Nehmad (15:59):
It would solve a
lot of problems, I think. Cool.
So these are the 3 proposals wewanted to mention. Let's quickly
do a lightning round. Lightninground.
Jonathan Hall (16:15):
So the first one
I wanna talk about is a little
library called QRand. If youdon't think, math rand v 2 is
good enough or crypto rand isgood enough, you might try
QRand. What does it do? It givesyou quantum random numbers. It
does this by talking to the ANUquantum numbers, API.
You didn't need an API key,although it's free for certain
(16:36):
low volumes of usage. Thislibrary comes from, John Aranda
who we've had on the showbefore. I haven't used it, but
it's just cool. Quantum is cool.So, you know, if you want some
quantum random numbers, now youcan do it.
Shay Nehmad (16:48):
Yeah. There's a
nice quote in the read me.
Random numbers should not begenerated with a method chosen
at random. Like, only use thisif you think you need this.
Right?
Well, my thing for the, blogpost is not really my thing.
It's, Mihai's thing because heposted it on the channel.
Thanks, Mihai. It's a reallygood, blog post called I Stan
(17:10):
Clearing Maps, No Cap by PhilPearl. It's just a story of
someone, debugging an issue withmap and capacities at work, a
very real blog post about a realthing, and it references a
rejected proposal, which is myfavorite kind of proposal, the
only one I like to submit, onesthat get rejected.
(17:32):
And it just shows, like, abenchmark of, hey, why this,
took so much time, somethingthat I ran into at work, and
also a very, boring, solution atthe end that's very problematic,
which I really liked. So go readit. I'm not gonna spoil the
ending. And that does it for thelighting round.
Jonathan Hall (17:49):
Dun dun dun.
Cliffhanger.
Shay Nehmad (17:51):
Mhmm. Cool. Let's
move to the ad break.
Jonathan Hall (18:01):
Alright. Well,
thanks for listening to our
episode today, this week. If youenjoyed this episode, be sure to
rate it or review it on whereveryou listen to your podcasts and
share it with a friend or acolleague or a fellow student or
your pets or whoever would like,word-of-mouth, because that's
how our shows, is spread. Wedon't pay for any advertising.
So, yeah, the best way you canhelp support us is to just share
(18:23):
the show with your friends.
You can also support us onPatreon if you want to. This is
a hobby, and it's not free.Wanna help with the hosting and
editing fees? Cupago.dev, youcan head over there and click on
the Patreon link and become asupporting member. Do we have
new ones this week, Shai?
Shay Nehmad (18:37):
No. But, actually,
we have a churning member, a
person who left, and we totallyrespect that as well. We
appreciate your patronage whileyou were here. Yes. That's
solely fair as well.
A few programming notes. We areat the month of December, which
is cold and also full ofholidays and many, many things
to do. Next week, we should befine. 19th December, I'm on
(18:59):
vacation, and we are looking fora replacement co host. If you
wanna step into my smelly shoesand, co host the show with
Jonathan and 19th December isfree, talk to us.
Send us a message on our, Slack,hashtag a cup ago. You can find
us on the channel. You can DM usas well. But, yeah, we need
someone to fill in for mebecause, I can't do the 19th.
(19:23):
And 26th is like Christmas, sowe're gonna take that week off.
Also, very very excitingly, thisis gonna be our 91st episode.
Meaning, we are creeping up on acentury of a cup ago, which is
totally not my expectation whenwe started the show, and it's
pretty amazing. No. John and Italked about how we're gonna,
(19:43):
like, celebrate or do something,and we think about doing a a
live episode just with y'all,like, having everybody on the
call and just sort of a onlinemeetup, live episode kind of
thing. If that soundsinteresting, let us know.
If that sounds horrible, let usknow as well, on the channel. We
(20:06):
might I will send out a surveyso you can upvote and downvote
when this episode comes out.And, yeah, if we have a lot of,
engagement
Jonathan Hall (20:13):
That that episode
will probably land around little
or late February depending onhow many weeks we skip between
now and then.
Shay Nehmad (20:19):
Yeah. Maybe we'll
do, like we wanna keep it in
February. Maybe we'll do, 5episodes a week. We'll just do a
couple Goathon. That soundspretty horrible because we'll
run out of the stuff to talkabout pretty fast.
But, yeah, we are thinking aboutdoing a live episode to
celebrate the fact that we'vedone a 100 of these things, or
we will do a 100 of thesethings, which is pretty
exciting.
Jonathan Hall (20:39):
Yeah.
Shay Nehmad (20:39):
So if that sounds
interesting to you, let us know
on the Slack channel and, we'llmake it happen. And that does it
for this episode this week. Bye,program exited.