 So run of the plus for the first talk Rashmi and the slides are here Hi, everyone, I'm Rashmi and I'm a software engineer based in India So my top title is go for the JavaScript developers. So let's get started Go is like the sea and the python has a kid So it's a common saying that go possesses the confidence and athletic ability like a sea And it has the same good looks and the pleasant eminor like a python So what exactly is go it's an open source compiler and garbage collected concurrent system programming language Which has blazing fast because it has our young compiler with minimal speed optimization and old So it has a strict compiler and so it's something like the things like unused imports and the unused variables or hard compile errors and go and It possesses clean and elegant syntax So what are the similarities between the go and the JavaScript? So both uses the garbage collection and the variables and the functions. They have a specific scope and In similar fashions they define the variable structures and for loops and if statements What are the major differences between the go and the JavaScript? So JavaScript is a single threaded that it has the main thread which is which does this event loop And there are several other threads which do the external input output while in the go The concurrency is the king in the sense that it has the go routines and the JavaScript is interpreted language It runs before it is the code is compiled before it's trans while go is a compile language And also in go we can have a multiple return statements that is if you have let's say an error called 500 internals of error or something like that particular functions can return the multiple error codes So it's very consistent and it's easy to maintain So basic rules that the lines don't have don't end with the semi-colon and so it's a Very simple example is declaration of the array of size three which has integer values One two and three and there is a comma at the end of the three and the basic types like Where num end is equal to five so declare so it says that the variable name that is numb It's being declared before the integer the data type itself So in similar fashion the for loop and the by loop to the similarity which we can see in those of them is that there they don't have the parentheses and In the same way the Flow control that is there is no parentheses and if statement it returns false when the age is less than 18 or So what are the so there are some of the advanced features and go that are the code routines Which I already talked before that concurrency is the king in the goal which so the go routine is basically a lightweight thread which is managed by the go runtime and So here go funk. I mean the function and the ABC are the three parameters So what happens is the function and the evaluation of the ABC will happen in the same thread itself while the function will the function will be executed in the in the different thread and The channels they can be thought of as the pipelines or the pipes like In which the go routines themselves communicate and they also possess a type of see it with it That is the data which is allowed to transport to that particular channel And it's being declared using this operator that is a channel operator here We can see in an example that channel be since we is being sent to the channel see H and similar way And how we are assigning the value to the we is I mean that channel Receive the value from that particular channel and assign it to do a variable that is V Okay, and the person takeaway is that those are not get started with the go It's never too late to start something a new all a Fresh all it takes is practice patience and perseverance. I really want to thank Carolyn Rita and my teacher for helping me I mean getting introduced to the goal language and thank you for inspiring me a lot Okay, so up next Tom Ash Brando plus for him to please okay So hello, I'm Tom Ash and today I will show you my debugging adventure with go long so one evening my colleague was deploying a service on our infrastructure and What happened it the service was not up here in our production It was deployed, but it wasn't attached to load balancer and console which was our discovery solution So I asked him hey try deploy it one more time, but obviously it doesn't help and So we started the backing like what could be a problem? at the time At the time our infrastructure was built on Marathon with our application scheduler console Discovery solution Marathon console which ties application develop deployed on Marathon to console and the service that was deployed So we had like a three hundreds services and only one has a problem So what has happened this application has exposed two ports one for admin and one for the rest of the world each port has a tags and Both ports were registered with the same tags. So because it was stuck with has the same tags one port disappear from console So what has changed because this service was deployed many times a day One tag has been up and So at the time we have 80% of our Application has only one port eight percent has Tags and only one that fails has multiple target port. So let's take a look at code and Here's a bug like something here So what happened? we just add one tag and We end up with two same slices I will unroll this for loop for you so it looks like this and You can guess what function a and function b prints Like I haven't been expecting this at the time. So what happened? Yeah slices When we what is slice slices just three elements like a pointer to a All right length and capacity and when we append this to the slice and it has a sufficient capacity we only change the last element and update the length So in our example it looks like this we start with a slice like this then up an element then up and next element and Next element finish with three variables pointing to the same space in a in a disc in a hip So yeah, when we run this we and print Memory locations we see that everything is in one place Yeah, and in our second example like these pointers are Different so Yeah, I was expecting to slices to work like this every time Unfortunately, they do not work like this. So be careful when using happens Do not append to slice when you want to Keep unchanged Yeah, and remember you are never working on a copy of your data Okay, thank you Quick question, how many of you have been beaten by this? Yeah, okay good Same okay, so next up we have Yana And Ronald plus for her Hello This is my eight here at foster fifth at go the other met foster So it's been a wild ride and I have no intention to speak here But I saw this room and I was like this is legit legit I should at least give a lightning talk. So these are some like style tips I have for go packages because I signed up to be a Go riddable to reviewer for a long time at Google and like some of this stuff is really obvious But it comes very often. So first of all if you need any, you know style guideline tips Feel free to reach out to go like knots or to go for slag You should also check out the code review comments. This is just like general tips and This entire presentation is also Available as an article on recal that arc style dash packages So the first thing is about organization because organization is what matters You try to use, you know multiple files go allows you to Split your package in multiple files and you can just you know create some Logical separation for example, you can this is the HTTP package And you can put all the header related stuff in headers that go Cookies related stuff in cookies that go all the core stuff maybe an HTTP dot go Or maybe it will get too long and you can split it and as a client that go and you know server dot go Try to use multiple files. The other thing is keep types closed For example, the core header type can maybe fit better in the headers file because all the other methods and like other functionality, maybe some utilities will go there Some people usually make the mistake of like putting headers type into the HTTP dot go file because or at the Initial, you know enter point of the HTTP package because they think that this is a core type But try to you know put it in where it makes sense Because you want to be able to you know jump back to the type and see and you know use it as a reference It kind of helps you with you know when you're reading the source code The other thing is organized by responsibility. I came from you know See and then later Java and I had this like especially because of the Java background. I had this Habit of creating for example of models, you know package I would put all my entities there in go. We don't do this. We instead put everything by responsibility in their respective packages For example, if you have users that's cool If you have a user service type of package or like a management package put the user into there because this is where you know You know there that you will also put functionality to return your users in that type of stuff Provide examples in God Godox. This is really actually cool because go allows you to embed snippets in the Godox and Especially if the usage is not trivial This is kind of like giving your users a way to like copy paste and like you know quickly just get an understanding of how to make a call To the function and there's a really good blog post actually on the go block about this Go examples Godox examples are testable. So you write them as test functions and They are run as a part of go test. So, you know, they are compiled tested and They are never get an absolute because they are a part of the go test I will say that like, you know, try to optimize for Godox because This is something like when you're designing the API initially try to take a look at what is, you know going on on the Godox I'm not suggesting that like you organize entirely But try to have a sense of what it how it will be represented it because Godox will be the you know Entry point of your users and I said go space doc because Francis told me that like it's you know The other stuff is deprecated but Go space doc HTTP will be only available in one point eleven So you better try to you know, take a look at the current offer whatever the official name because there's no RC but Either use Godox or wait for one point twelve anyways Put binaries in a command. This is very common like all the like main functions should go into slash command Like this is the go tool in the gore core repository. I will talk about some naming stuff Lower case stuff only no camel case. No like underscore short But representative names no common no util if you want to use util use like some context like say HTTP util try to enforce when it URLs if you have this like fence URLs you can enforce them and Write some docs please document a page. You don't have any excuses and use Doc go if you have very long documentation so people can just you know jump to that file and like read as a maintenance Release and that's all take a look at these links Okay, and up next we have go performance tuning cool and a brawl bus for him Whatever his name is Hi, I'm Richie. I'm a developer on uber's open source metric stack and three which is all written in go This is originally a 30-minute talk, so I'm gonna speak very quickly I cut out a bunch of stuff, but this is basically a war story from production So basically uber has a service called the ingestors And their job is basically to just receive metrics at like regular intervals and then write them to storage as quickly as possible So one day we deployed our ingestors service kind of like routine deployment Because they hadn't been deployed in a few months And you can see that the end-to-end latency Before we deployed it was like 10 seconds and after we deployed was over 20 seconds So this is really bad because it means graphs don't load as quickly and alerts can't catch issues as quickly So you want to keep this p99 latency low? So we try to figure out what went wrong and that was really tricky because this code was in a mono repo So we're like hundreds and hundreds of commits and we hadn't deployed in months So we weren't sure which one affected it So long story short. We did a get by set in production, which is terrible But we found the issue And it was this I don't have time to delve into the details But basically the code on the right is almost the same as the code on the left It's just code that was in line got moved into a helper function We're like, okay, that shouldn't make it that much slower like calling functions isn't you know isn't free But it's not that expensive. It shouldn't make things twice as slow So we're trying to figure out what was going on We ran a bunch of microbenchmarks that showed no performance difference between these two versions of the clone function So sometimes microbenchmarks lie, but we took flame graphs of both services running in predict production And again, it looked like the service was spending the same amount of time in both versions of the code So we're really confused Kind of out of desperation because when CPU profiles don't work. I kind of lose my mind We SCP the binaries down and ran go tool object dump on them to get the assembly and Long story short assembly is almost the same The only thing we noticed though is that the clone bytes, which is like the helper method I was talking about earlier ends up not actually getting inlined Which got us thinking and we went back and looked at the CPU profiles turns out CPU profiles don't lie humans just make mistakes and There actually was a pretty big difference in this one function called runtime.more stack But we're like, oh, that's a runtime function runtime's always correct. Like can't be my fault Turns out that wasn't true so we dug into this tried to figure out what this function does and Turns out and go every go routine starts with a two kilobyte stack And then when you call a function the runtime checks if you have enough room left on the stack to call the function If you don't allocate a new stack twice as big copies all the stack frames And then resumes execution So our new theory was that in production our call stack was so deep and we were right on the edge that when you called clone It would push you over the edge and you'd allocate like a four eight kilobyte stack which expensive And in the benchmarks the stack was really shallow. So you wouldn't do that thing So like okay, let's try this out Basically in our ingester service all the code gets executed in this worker pool Pretty standard basically allocate a go routine for every piece of work So to test this out we wrote a new one where you allocate all the go routines up front You never let them die they kind of hang around in the background and then you assign them work via channels Instead of spawning them constantly and then you pay the stack growth cost once right and then you never have to pay it again so we roll this out to production and The code on the left the arrow on the left is showing us rolling back through aggression So you to see the latency comes down the arrow on the right though is when we released the worker pool So it actually got even faster than it was before so we're like, okay, cool We actually made this faster than it ever was originally Which is great, but we were like we haven't really proved anything like there's all kind of like incidental like couldn't send someone to prison over this, right? So like okay, let's just fork the go compiler and figure out and add some print statements because that's how we debug everything And see if this is actually happening So we forked the go compiler added some sampling so that we wouldn't be printing millions of logs Compiled our service with the fourth go compiler threw it up into production again because that was the only place for this issue would manifest Wouldn't show up at staging Immediately started seeing logs like this where it's saying okay like around the clone bytes function I just had to grow the stack from four kilobytes to eight kilobytes. So if you put an eight kilobyte allocation In the hot path of your code that could definitely explain why it gets twice as low And then we just basically counted the number of print statements and we saw that with the regression There are a lot and with the new worker pool there was none. Okay. Thank you. Thank you No, no you Okay, so up next we have People need to put their names my cape John. Oh John. Okay, cool. So up next we have John. So Rob was for John right So this is gonna be a little bit lighter than that sort of technical deep-dive that we just had and it's a little tool It's a little sort of and package. I wrote myself to sort of Scratch an itch that I had where I was finding myself constantly sort of running commands to check the status of things Things that I just wanted to keep an eye on and I thought I'd be far better keeping them up in the menu bar So I ended up writing a package to help me generate Plugins for Bitbar. So Bitbar is an application written by Matt Ryer that runs an OS X that sort of Handles the rendering of menu bar applications and has like a super simple interface And you literally just have to drop in an executable that outputs text It can be any language. It can be shell scripts Absolutely anything and then you can control how frequently the that refreshes just by appending Sophics to the files like dot 30 seconds dot one minute and so on So I created a package called go Bitbar after having originally written stuff using templates And it was you know all very hand-rolled very difficult to sort of explain to somebody how to use And like as I said the main reason is that you you can put pieces of information that you want up in your menu bar So they're very quick to get to if you've commands that you're constantly executing You just would like to to get access to you can just pop them up there and because you're writing it It's completely customizable and you can write it in go which is good And so using the package. This is what an absolute minimal Menu bar app would look like so you create an instance of the app with the bit bar and you you create a status line Entry so the status line is what appears in the menu bar So you can actually add a second one You can just sort of invoke that status line method a second time and it will rotate between the two pieces of information And then you you can add submenus and you can nest submenus So you can have like multiple trees dropping off one another and within a menu you add a line and you can add multiple lines And then you just finally call render and that's what you end up with there You end up with your hello and your world. So that's a really simple example And some of the kind of more complicated ones that I ended up putting together where for as a project I contribute to open fast and I wrote a Menu bar app that lets you sort of look at your open fast gateways and sort of see the status of all your functions and look at your Prometheus metrics just from the menu bar and which was kind of useful when you're when you're developing You maybe have left something running or you just want to kind of at a glance check what's going on and So you can see there the submenu and you've got action. So if you click on the action, that's actually gonna go and Invoke a command that deletes a function, you know, open the gateway open Prometheus They'll open chrome and open browser. So you can do pretty complicated things without having to write a huge amount yourself so like for example To to add a link to URL you just add a line So give the line about a text and then you use this href It uses a builder pattern to build things up the href just takes the URL So in this case, it's an SSH URL and it's just using OS X is open So that will just open a terminal and the terminal is true so that it actually doesn't suppress the terminal And but that could be a URL. It could be HTTP HTTPS If you want to execute a command so you can execute any arbitrary command But if you want to actually build some functionality into your plug-in what you can do is you can use Cobra Like Caroline showed earlier on and you can add extra sub commands So in this case, I added a delete sub command that in the rendering of your of your your menu It knows the host name in the context and you basically it just calls the plug-in again with delete and the name of the host name and The terminal is false because that stops the terminal popping up So it just goes ahead and deletes it and you don't see a terminal pop up and the refresh true Automatically refreshes the menu bar. So you get the latest information. So some other ones. This is this is some very very lazy and Opening a browser is too much work And I have a menu bar app that shows a traffic camera from my trip home so Some links so Matt Ryder's Bitbar app is on get bit bar. I'm always surprised at the number of people who haven't actually heard of that It's it's really really awesome. And there's a link to the package for building your own plug-in Thank you Okay, and last but not least Run Evans And I'm gonna give you a little bit more than two minutes You have like maybe five minutes because we have the room to close and I know that yours is complicated Yes You do you this So the demo is setting up projector with Linux The more intelligent the speaker the more AV problems have no AV problems Yeah You ready cool run all of us for run Okay, everybody Before I get started, I just want to say let's give up a big round of applause for Francesc and for Margie they have done an amazing job organizing this come on give it up for them There were others, but I can't pronounce their names. I'm really sorry. I could better pronounce yours All right, so I am dead program run Evans in the real world dead program on all the internets I run a small consultancy called the hybrid group We do software for hardware companies and I really like robots But you probably know that you may have seen me talk about go bot Which is go programming for middleware for robotics or go CV, which is computer vision then go using open CV But today I'm here to talk about a really cool new project that I've been collaborating with my colleague called tiny go So it's a go for small places Really small we mean like microcontrollers in other words devices that have between 8k and 32k of RAM I did not say megabytes. I said K Thousand small right or web assembly, but you know, we'll get to that in some other future time So everyone says go is too big Right, everyone says go is just too big Well a gopher is a gopher no matter how small Actually Dave Cheney did not say that but doesn't that sound like something he would say So thank you Dave Dr. Dave So I'm gonna show you right now that go can be tiny. Yes, it is true I am gonna show you and I'm gonna show you with this. Let me put the mic down for a second. Hopefully not Even though I appreciate that I might Wish I'll see So first I'm gonna run a go CV program. So I've got my camera Hello, okay, and so now I'm gonna show you the microcontroller. I'm gonna use which is this itzy bitzy Literally itzy bitzy M zero. It's made by Adafruit. It is a really cool little board. I Kind of almost do need to answer Three whatever More All right, so the itzy bitzy is a micro chip the company that bought at mal samd 21 It's an arm cortex M zero. It's a 32-bit processor 48 megahertz speed and 256k of flash memory 256k all right, so let's do this The whole world of things using tiny go is a very simple little go program Package main we import machine which is our package from tiny go how we integrate with the actual hardware devices The time package you've seen that before and then our main Our first thing we're gonna do is say led equals machine dot GPIO machine dot led So we're saying this particular machines led We're gonna configure it to be a GPI output That means we're gonna send something out versus receive a signal in and then for ever first We're gonna set it to low in other words turn it off. We're gonna sleep for 500 milliseconds then we're gonna turn it on and Then sleep for another 500 milliseconds, so it's the whole world of things as a blinky light So let's see if this works first. I'm gonna plug it in It's plugged in. I'm trying to talk into the microcontroller Next demo Next demo Okay, so the first thing I'm gonna do is I'm gonna press the little button on this twice to put it into the bootloader mode So I can loot load new software. I can't show the can't show the camera That's kind of cute. I should keep I should do that on purpose So we're gonna load this code by compiling it first. Okay, so we just compiled a bin file So let's look at how big that bin file is real quick So we can say that is a 2376 bytes in size okay that program so let's put it on here So we're just gonna convert it Into a hex file which then is gonna convert it into the uf2 bootloader format So it just copies it on there and now if we go to the camera We can see it is blinking Yes, it is real How can you do that? It's not impossible Well, luckily the go compiler tool chain itself is written in go And then there's this other thing called the LLVM Which is a actual toolkit for building compilers So if we put those things together we can use goes front end to put it into ssa form Then use tiny goes compiler to turn that into the intermediate representation that LLVM uses and then use LLVM to generate binary code So it's a different way. It's a different gospel of the go compiler if you will So you want to know more? Tinygo.org we have a great website that has been put together by the founder of this project IK Who's actually in the back of the room kind of embarrassed right now? And a bunch of other collaborators also come see my talk tomorrow Building K. That's the big building in La Fontaine 11 a.m. You should be there Why because first of all it's the first ever FOS damn main room talk about go. Isn't that incredible? And it's a very small go So there will be prizes thanks to a the fruit and others So if you show up you can maybe win something so definitely don't miss it Main room building K. La Fontaine 11 a.m. Be there be there be there Also the very first ever tiny go bof will also be tomorrow at 1300 hours so after we've all kind of calmed down from the drones flying around and stuff We can talk about like this. So thank you very much With this amount with this We are done. So thank you very much everyone for coming special. Thanks to all of the speakers without you This won't be possible and what? Yeah, so we are all grown-ups and responsible So if you brought some trash take it out with you if you didn't break any trash But there's some around you take it out with you and if you're interested on seeing me suffer tomorrow I'm seeing a whole day. I will be at the ML on code broom. So I'll be there. See you tomorrow