Brief Intro to Go (lang)
It seems like it blasted overnight in fame. Six years prior it was open sourced and before that it was a closed source. The entire thought was as opposed to composing exceptionally enormous servers, with huge machines, numerous centers, numerous engineers, all that stuff.
In this way, with Go essentially what they tried to do is, let’s expel the majority of the fancy things and go down to the most straightforward tool that can carry out the responsibility. That outcome is Go.
I used to compose C++ and I accepted that so as to compose amazing things, you required a powerful language. But when I begin writing in Go, I understood that that was in reality entirely wrong because at end of the day, if you have a basic instrument that is cool, that works great.
Interestingly, the tool is so straightforward, it really allows you to focus on the issue you’re trying to tackle as opposed to how you’re settling it.
Kubernetes isn’t that simple. But it’s using Go. It allows people to understand the concepts of how Kubernetes works, and it doesn’t take that long to understand how that translates into Go. Go is easy to read. That’s the point.
So, when we’re discussing C++. I’ve written some code in C++, you’ve got to do all this allocation of memory, de – allocation, pointers, it’s crazy.
So, how does Go manage C++’s power but keeps it simple?
You have to do all the things in C++. You are not permitted to do any of the things in Go, that’s much simpler. You’ve got pointers, but you can’t remove them. There’s a garbage collector doing all the stuff. You don’t decide whether on the heap or on the stack something is being allocated, you don’t decide.
As a C++ programmer or like low-level programming, there are many of these things and you’re like, “How am I going to do anything with this?” Then you just give up, accept Go’s way, and just start writing code. It’s actually very effective, surprisingly and at the end of the day, on the memory side of things, it’s actually about the same performance as C++.
Last but not least, all this is still really fast. How did you begin to work with Go? It sounds like it’s been around for a couple of years, and you’ve become one of the experts on it de facto. I would love to know how you began. I wrote C++ and somehow I became a C++ expert. I ended up at Google writing C++ when I decided to do something new.
I decided to do something new after a year or so. I found Developer Relations as the thing I love. Also, as I did my Masters on compilers and optimization, I decided that both of them would be fun to merge. So, I ended up doing Relations for Go for Developer. My first job was to learn Go and return to the experience with feedback. Looking at it with fresh eyes. Wonderful.
Rather than seeing documentation for the fmt package, there are better ways to do that. My favorite is go doc. If you do this package doc, you’ll receive the same message. We do go doc fmt, you’re getting a lot more than that. In fact, you’re going to get the complete documentation, which is pretty big, with all the different functions in fmt.
What if I’m concerned about a particular function?
Well, I can go doc fmt Printf, and I’m going to get the documentation for that particular feature. Another option is to run the -http-based doc binary and give it a port. Now, what you’re doing is actually listening on port 6060 when you run this. So, you can see the packages when you visit it. In my machine, I can see all the packages.
That’s cool, not just the packages in the standard library, but all the packages I’ve ever downloaded. So we can find Gorilla and Gorilla mux, for example, which is something I use regularly. Which means that even when I travel around and I’m on an airplane without connectivity, I have access to all of this documentation.
So, that was Go Tooling in Action, the tutorial that all started. In fact, it became not just a tutorial, but also a workshop.
So, someone who is interested in learning Go, where to start?
Golang.org is Go’s website. So, that’s where you’ll find all the stuff. There’s a tour that’s really useful, I recommend trying it, you don’t have to do the whole thing on the first day. Don’t worry about it, but try it definitely.