Good morning everyone. Finally I can hear you again after two years online where I just
had to stare at a boring matrix chat. I am honestly so glad to be here and welcome everyone
back. Just like every year we are starting with an update with the state of Go. We are
going to talk about what is new in Go. I will quickly touch on some topics. The interesting
things about Go come in later talks. So what I am going to look into today is change the
language as well as the standard library, tooling of course. I got two interesting design
drafts for new releases in Go and of course an update on our Go community. What is new
in Go since Go 180? Well of course Go 119 was released in August of last year. Go 1.20
was released a few days ago. It is just the first time that they released a Go version
before I do this talk. What are the big new changes? There are four new changes to the
language as the most we ever had. However one is not really a change so it is more like
two and a half changes but actually more like 2.25. Let's just keep it there. Two real
changes to the languages addition. The first one is that there is a new syntax for converting
a slice to an array. Those of you who are new to Go might be confused because what is
the difference between a slice and an array? I call them both arrays. Well technically in
Go an array has a fixed length and the slice does not. That is too easy to say it is not
correct. But you can go verb between those two and you could have done so since Go 117
using this ugly syntax which has to do with pointers and how it works underneath. I would
have never come up with this myself. But in Go 1.20 it is more logical now. You can just
make an array with a fixed length of 3 and put your slice in it. This now works. The
next change has to do with generics which were introduced just last year. It has to
do with a comparable constraint which we could give to variables. You could say a variable
has to be comparable. Why would you use this? For example when you have to loop over a map
it has to have a comparable key. So you could write something like this to make a sum of
some numbers. And you can use it wherever you want. You make a map from strings and
ints and it will count this. Okay strings will work because they are comparable. How
do I know that? Simple. You can compare them with equal signs. But what about the empty
interface? Is that comparable? Well that depends what the interface is. Before this was not
valid. You couldn't do this. But in Go 1.20 you can because now we have two types of
comparables. You have strictly comparables like ints, string, bytes, usual, but also
non-strictly comparables like the empty interface. Do be careful because this might panic at
runtime. It's allowed but it can panic. The next change is the comparables of strict values.
It now checks one property at a time and it will exit at the first mismatch. Wait a minute.
This was always this way. Yes, it was always implemented this way but it was never specified
in the language specification. This isn't really a change in the language. The next
change has to do with three new unsafe functions. This is the unsafe package. You should just
avoid doing this. Next up, what is new with the Go Tooling? Well, I say this every year
and before me, Frances said it every year, is that there are new warnings in Go Vats.
Why should you care? Okay, there's a new squiggly line in your editor. You might not care about
those squiggly lines in your editor. You should but you can't. Okay, but it also runs when
you run tests with Go tests. So your CI might suddenly turn red if you update your Go version
because there are new warnings. That's why these are important. The first new warning
this year is in Go 119, that it will now error when you pass a pointer to an error in the
Error.Ask function, which is such a common mistake that kid of co-pilot wrote this code
for me. It's not bad. It doesn't work. The next warning has to do with incorrect date
formats. Let's say I want to format a date of today in an ISO-like notation. Well, I
would write some code like this. But wait a minute, let's think twice about my codea.
How do I format a date in Go? Well, you always have to think about Monday, January the second
of 2006. This is February 1st. Many of you probably haven't noticed. Again, this is a
common mistake because people are confused between 1 and 2. Go Vats will now warn you
against the above format because it probably is used nowhere. There are also some welcome
changes to Go Dock. You can now make lists, link, and headers inside your Dock comments,
which will be rendered into HTML. Use an example below where I put a header in, I link to the
RC I'm implementing, and I'm also listing which guys of coffee my machine supports.
There is also in 119 a new Unix build constraint. If you want to build a file that only will
be built on a Unix system, you can do that using Go column builds. Okay, in the past,
you could do it by listing all different Unix systems. There are a lot of them. Okay, that's
a lot of code, right? Well, in 1 to 19, you can just do Go column build Unix. Wait a minute.
Isn't this a common thing to do? Because a file system in Unix is almost the same everywhere.
Okay, so I asked chatGPT, like every developer does these days. I asked, give me a Unix build
constraint, and it gave me this thing. Go build, not Windows. Okay, you all know what's
going to happen, right? Okay, you say, it's an AI, I trust the AI. Let's think tries about
this. Don't try to be smart and reach the actual compiler code, like every one of you
does all day. And immediately I found this thing. Oh, JavaScript is a thing. WebAssembly,
one important fact I didn't even talk about if Plan 9 is Unix or not. No, I just love
like JavaScript. That's not Unix, and it's also not Windows. So just don't trust your
AI, please. 1.20 ads also coverage on building binaries. Why should you care about this?
Well, many integration and end-to-end tests, you run them by making a special binary, running
it, and getting your test results. If you also want coverage results, this wasn't possible
before. If you now build it with dash cover and at a co-cover deer environment variable,
then run the script, okay, you get your output, and you also get which lines all your code
touched, so you can put it in your site, your favorite coverage tool. There are also a few
small changes I want to touch upon. C code will now be disabled if a C tool chain is
not found. Many container people will now be happy. Go generate and go test also have
a skip flag, which you can put in the red text for which file to skip. Okay, let's take
a look at the standard library. Go as many things in the standard library, and of course
we have changes in those every year. The first one is in 1.20, and I find super useful. You
can now wrap multiple errors. You can do so using error.fmt.errorf. You can now put multiple
percent sign w in there. You can just wrap multiple errors. Your functions that you will
run on them like errors.is or errors.s, just loop over all those errors. It does that by
using the underlying new unwrap interface, which just gives you the slice of original
errors back. There is also the new errors.join function, which you can just throw all your
errors into. Why would you use this? Okay, you always written a code like this. You just
loop over a list, and you want to check for some errors. Okay, you could just return a
slice of error, but then you have to check for the length, if it's not nil, etc. Okay,
you just want a single error out there. You can use errors.join, and you get a list of
all your errors, which are joined together. You can just treat it like a normal error
in your code, and even use errors.is and errors.us. So you can just say, oh, was there any empty
string in this list? There are also a few changes to the strings and byte package, which
is that it now has a new cut function. It just works as an act trim with trim prefix,
cut prefix, and cut suffix, except it will now return a boolean if a cut has happened.
There is also a clone function, which returns the same instance copied in memory. Also,
few small changes to the time package. We now have a compare function, which is a combination
of before and after. It does both. It will return you an integer from either minus one
plus one or zero, depending on if it's before, after, or the same as a given time. There
are also three new layout constraints, which you can use, and those actually came from
you. Those came from the Go user survey that they are commonly used, so they added time.
There is date time, which gives you an ISO-like notation. There is also date only and time
only, which gives you only the date and only the time. There is also a change in the TLS
package like every edition. This time, it's a change in how it treats memory. It now shares
a copy of your certificate in memory. Why is this useful for you? Well, let's say you
have an application that does many concurrent connections, like Kubernetes. Well, until
then, now it's sort of a copy of your certificate for every connection in memory. It now is
sharing those amongst multiple connections, so you are saving memory. If you somehow have
an invalid certificate, you also get a specific error that says the certificate is not valid
instead of a general error. And yes, we also have breaking changes this edition in the
standard library. The first one happened in 119 in the HTTP package. The HTTP client
will now no longer give an error back if you serve a sense of 300 response without the
location header set. If you rely on your code to check if the location is set or not by
using this error, yes, your code will break now. Also, a change in the random package.
It is now preceded when you use the global random functions. You no longer have to call
the dot seed function with some random number you get from somewhere. It now does that for
you. Of course, it deprecates the dot seed function. If you still need your own seed
for predictable random numbers, you can do so by using the random new function. If this
somehow breaks your code, it could. You can disable it using this new go debug variable.
In tar and zip, there are also some changes which are welcome, which is that it will now
error if your R guy has an absolute pot, an invalid character in a file name, or a reserved
name on the Windows platform. It will now return error in secure pot. This to protect
your server from being hacked. If you somehow don't want this, you can also turn it off
in go debug. There is one new package in the standard library, which is the elliptic curve
of the helmet gear change. Yay. Very excited. This was possible. Go can do it using the
lower elliptic one, but you had to implement more yourself. So it's probably more secure
than you would. Okay. The go runtime. We also have a few changes in there. Well, go 119
has a revised memory model, and I have no idea how they did that. I don't know. So if
you want something, we actually know what he's talking about, Russ Cox wrote an amazing
blog post about it. But what does this mean for us average go developers and not compiler
developers? Well, first of all, go now has a soft memory limit. You can now tell go how
much memory you wanted to maximum use. It's a soft limit. Okay. You can, for example,
set it to be one gigabyte. Okay. What will happen tomorrow? Go towards one gigabyte limit.
It will try to trigger the garbage collector more to get more memory frets. Yes, you can
see the results if it's too low. Well, what will happen is if it's too much, it will try
to limit it to 50% of the CPU execution time, which your process is using to be garbage
collection. There is, however, a warning. If you set it to tens of limit, tens of megabytes,
it might just work because your operating system says that's absolutely not enough.
This also results in a new atomic package, which provides low level atomic memory access.
So you could now access these variables in multiple go routines. It works only for primitives
like integers, booleans, and unsafe pointers. It does this by exposing the function store
and load. Also add for integers and compare and compare and swap. Okay. But if you use
these, you need to know exactly what you're doing. You need to know how our topics work.
As always. And it's still not really recommended. They recommend that you still share memory
by communicating, for example, with channels and not communicate by sharing memory. So
please only use this as if this is your only option. Go 1.20 has a few small changes in
the runtime. The garbage collector got better yet again. Say this every year for five years,
it got better. And it is now a Leatheretic. There is also a new mode, which you can compile
the binaries in, which is P go, which you can give it a profile of your program that
has been running, which will now will try to optimize the binary towards your CPU profile
from a previous run by, for example, inlining frequently called functions. The go team claims
that is up to 4% faster. I had some colleagues who were looking into this, but not in time
to get actual benchmarks. At last, I want to give you a small update on go ports. So
what is happening on the ports in go? Well, go 1.19 added a new processor architecture
on Linux, which is long arc. It's a Chinese built architecture. It's not yet in white
use hour. Go 1.20 will be the last one to support Windows 7 and 8. It will also be the
last one to support Mac OS 10.13 and 10.14, but who cares? Go 1.20 also has experimental
support for RISC 5 and the free BSD platform. Yay. Okay. That is the current version of
go. But of course, let's take a look at the future. And always we try to look in the future.
It won't always work. I have two interesting design drafts, which I found. The first one
is one for structured logging, something you all do, but doesn't work in the standard library.
There is a proposal to make an S log package in log in a standard library. They want this
to produce machine readable logging. And it hopes to replace the many, many, many, many,
many structured logging libraries like log RISC that ZLog, log arc, log, HLOc, and however
you pronounce all those. It tries to propose something like this. Something like every
library probably already did is you set up for something, you set up what you want to
send it to, you put in messages, you put in variables, and it logs those out in something
that is machine readable. This is the text output, which is just key value peps. So your
computers can all read it and can index it and make it searchable. How does it want to
do this? It wants to give you a logger interface. Again, these are all interfaces. You can just
implement them in your own library. Okay, it wants to give you fellow functions like
info, error, warning, log attributes. It then makes those into a record. This is just a
track containing all this data, and you give this record to a handler, and this handler
will turn it into something that's machine readable. If you want JSON, you just give
it to a JSON handler. If you want some proprietary format, you just make your own. So it tries
to give you an implementation and interfaces in the standard library for different log
levels like debug, info, warning, error, passing in data to be printed out, and now putting
it into text in JSON and maybe more formats. Again, this is a design proposal. It's not
yet implemented anywhere. If you have strong opinions about logging, you can read the full
proposal on this link. I will publish the site of FOSDM later today, and you can go
there, read everything about it, and leave some comments in their issue tracker.
The next big thing they want to tackle is Go version compatibility. Why do they want
to do that? Well, we've been doing this talk ever since 2015. A lot has changed, bigger
room, different speakers, and especially different slide templates, but there's one thing that
always stayed the same. It's this slide. Freaking changes. We wait a minute, Marcia. Isn't
there the Go 1.0 compatibility promise? And yes. Well, Go's emphasis on backwards compatibility
is why we all use Go, because we don't have to rewrite our whole application every two
years. However, there are times which is not possible, for example, with external security
dependencies or just bugs that we have to fix. Okay, let's take a look at this in practice.
Let's look at the big Go project. Kubernetes again. When did Go break Kubernetes? Well,
more than you think. Just in the last version, Go 115 broke Kubernetes in some way by deprecating
the X509 company. 117, a bug fix in that part's IP broke it again. In 118, again, X509 broke
Kubernetes again because Go changed something, they deprecated something. And in 119, a bug
fix in loop path also broke Kubernetes. Oops. Of course, it's impossible not to break Kubernetes
somehow. But still, let's try to avoid this in a language. So we have a solution, and
it's a solution already we have today. Is that Go debug flag I've been showing on my
slides? Okay, what is this proposal? It is to commit to adding one of these Go debug
flags to every breaking change in the following releases. And also to guarantee that they'll
stay there for a few years or maybe forever. They also want to add metrics to it so you
can look at your program and see how many of those are there that you have to fix. And
also to put it in code so you can use Go call and debug to override it inside the code yourself.
Again, this is not yet fully implemented. There is a design proposal. You can read everything
on the link there and leave any comments. But wait a minute, Marcia, don't we already
have this? I have to specify that Go version in my modules file, right? Yeah, but what
does it actually do? Oh, I know. This says the minimum Go version to build it. No. It
will try, any version will just try to build it. It's just a suggestion. It might fail.
Oh, I know. It says a Go version in which it uses. Also, no, sorry. It uses the installed
version on your laptop. Nothing else. Oh, did I know. This says the semantic rule set
for the version. And yes, that is correct. But only the semantic rule set. So that slides
to array conversion. Yes, that is set by this flag. The octal numbers which got added
two years ago. Yes, that is also checked by this flag. But that's all. Okay, they want
to change this. And this is the Go toolchain proposal. They want to add a Go toolchain environment
variable which you could use to set a specific toolchain. Okay, I want to use the 1.20 toolchain
for this application. This will allow Go get to get a new Go toolchain just like you would
get your Go modules. Okay, but it also needs to change the Go command a lot because it
has to get your toolchain from somewhere and then first download it, check it, and run
it. That changes our tooling a lot. And also, there is a cool toolchain local if you still
need a local for some reason. Again, this is just a design proposal. I might be saying
that this is implemented next year. If you have comments about it, there is a link here
as well. There is also a proposal to add this to the Go mod file. So it's right under the
Go version. You say, okay, my application uses the 1.19 syntax which has to use a 1.20
RC for toolchain. So if you build this module, it will go download this version of Go and
build it using that. Okay, that's a technical thing. Let's talk about my favorite subject,
the Go community. This is a map of all Go meetups in the world. We are pretty much covered
everywhere where big populations are, but still not enough. What are the numbers? Well,
the professional Go developer network on Meetup counts 127,000 members. That's 8,000 more
than last year. There is sat news for the first time. There are now only 190 meetups that
seeks less than last year, which also results in one country being less represented. Probably
due to the pandemic. There are also the women who go and go break chapters, which is still
stable at 41 chapters, and Berlin is still the most active one. But now let's talk about
my favorite community, the Foslan community. Our deaf room is nine years old today. So
we've been doing this since 2014. Okay, small room. Anyone can see themselves? Okay, we
got upgraded in 2015, 2016. Okay, bigger one. We stayed in the same size for three years,
which was a crowd enough, and today even is full house. 2019, we got the biggest upgrade
ever. We got a giant room. And in 2020, we got the biggest room they could find for us.
But I regret doing that because a month later, we were all in lockdown. That caused our 2021
edition to be fully online for the first time. We all did our best. We turned our living rooms
into giant television studios trying to bring you some talks about Go. We learned a lot
of lessons. And in 2022, we brought you gophers around the world, which we had great fun
in producing. But hey, welcome back. This is something you'll never, ever see again
today. There was just one guy still sitting there. And he'll be here at 9.00 at 9.00 p.m.
Good. Let's talk about Go! Conference. You're all in the mood, right? So there is a Go!
Conference. You are here. Please stay. There are better thoughts than mine. If you quickly
catch a plane, right now, you can still make Go! Con Israel, February 7. Con 42 will still
be held online in April. If you want to go to New York, you can do so at April 28. Go!
Con Japan will be held online. Go! Con Europe will be in Berlin in June. Go! Con US will
be in San Diego in September. And Go! Lapp in Florence, Italy will be held in November,
which I have not officially confirmed yet. So we got an amazing schedule today. I already
want to talk all speakers for signing up to be in our deaf room today. I hope you'll welcome
me again next year. But before I leave you all, I want to give a few housekeeping announcements.
First of all, out of tradition, we have lightning talks at the end of the day. We reserve the
last half hour of the day to do five-minute talks. Those timing is strict. I will pull
you offstage. We have a CFP for those. It's open till 17.00, or 5 p.m. for your Americans.
And you can submit a tile till that hour at govres.gov.slide. I'll write it on the right
board later. You just have to fill out three easy questions. And if you fill those out,
I can welcome you onstage at the last half hour. So you have time to submit a talk. Quickly
think of something. Submit it. We need you. If you want to talk to us about, talk to us
about social media, you can do so by using hashtag Golan and hashtag FOSDEM23 or FOSDEM223
or FOSDEM, nobody agrees on that hashtag. But we stand to say with FOSDEM23. We're
also on the Fediverse this year because Boo isn't. You can follow us, mention us, like
us at godevroom at fosterdon.social. We have a social media responsible person this year.
We will be happy to reply to all your angry tweets. So this is a state of go. I first
of all want to thank the FOSDEM organization for welcoming us back in the ULB. I want to
thank all the volunteers who are helping to make this room possible, as well as the AV
team from FOSDEM, who makes my camera work. And everyone else who is working at FOSDEM.
And at last I want to thank all speakers for coming here today. And of course, you all
for coming to the Go Dev Room again. Thank you.