In this course, you'll learn to program with the increasingly popular Go programming language from Google. Starting from the ground up and assuming no prior knowledge, this course will leave you feeling comfortable writing small Go programs, and familiar with all the major features of the language.
Interested in learning to program? Heard good things about Google's Go programming language? Then this course is for you! This course, which assumes no prior knowledge of programming with Go, will cover all the major aspects of the language, from the very basics of variables, through loops, conditionals, functions, and even an introduction to concurrent programming. This course is the ideal stepping stone for anyone interested in learning to program with Go.
Introducing Go Right then. What we'll do in this module, I think, is talk a bit about Go as a language, so explain stuff like what does it mean when people say it's a compiled language, or it's statically typed, all of that kind of stuff. Then, we'll take a look at how to install it on Windows. Now, the reason for Windows is just that it makes my life a little bit easier, seeing as how my recording and editing software is all Windows based. But do you know what? I'm a Linux fan, and I can assure you, Go works perfectly well on other platforms too. So if you're a Linux guy, or OS X, or maybe another version of BSD, Go has got you covered. I just don't want to waste cycles walking you through what's essentially a dead simple installation on multiple different platforms, so I'll show you where to get it, but we'll only walk through a simple install on Windows. Okay, first up on the fight card, let's try and explain Go.
Hello World Okay. In this module, we're going to get hands-on, and we're going to start writing code. So, we're going to pretty much hit the module like this. We'll set up our Go environment and workspace. We'll crank out our first program. Right now it's just going to be a simple variation of the old favorite, Hello World. Basic, but fundamental stuff, yeah, so we can get comfortable with the basic structure of Go programs. I think we'll do a quick primer on Go functions, and we'll lay down some rules relative to the main function. Then, we'll see how to get our program running. Alright then, let's rock and roll.
Variables and Constants So how's about that for a module title? Variables and Constants, yeah? Total opposites, right? One's forever changing, and the other one never changes. Could almost say, a bit like me and my wife. Anyway, the way we're going to cut this module is like so. We'll look at a few different ways that we can declare and initialize variables in Go programs. We'll talk about some differences at the package level versus within functions. We'll talk a bit about types and some rules about types with Go. We'll talk about how Go passes by value, rather than by reference, and see pointers in action. And we'll give a mention to constants at the end. Now then, for the most part, okay, in this module we're going to demonstrate variables with a simple program that displays information about a Pluralsight subscriber, so their name, which course they're currently watching, and whereabouts in that course they're at, like module two, maybe clip six, yeah? So, just three variables, name and course, both are strings; name holds the name of the subscriber, funnily enough, and course holds the name of the course that they're watching, and then module, that's a float. It's going to hold a value of where in the course they're currently up to, so like we said, module 2, clip 6 would be 2. 6, yeah? Now, don't read anything into this program; it's just a demonstration vehicle for learning how Go deals with variables. Well, talk is cheap, right? Let's get coding.
Functions Hi there, and welcome to this module on Functions. Now then, if you're new to programming and maybe just learning functions for the first time, then you are going to want to buckle up, because this is going to be one hell of a ride for you. We're going to start the ball rolling by going over why we have functions, and why they're both so cool and so important. Then, we'll drill down a bit into some more specifics. We'll take a look at how we define functions, okay, so the syntax and things like that. Then, we'll look at some examples, probably starting off with the main function that we need in every program, and then we'll create some of our own small custom functions to demo the theory that we're going to be learning. Then, once we're done with that and we're all done with the basics, we'll introduce some slightly more advanced topics, but not in massive detail. We're a beginner level course, remember, so I'm not going to get all hardcore and deep with things like higher order functions, closures used to define functions, and all of that stuff, though we probably will give them a mention and a quick intro. The aim of this module being to get you comfortable with the basics of functions, able to write your own, and to wet your appetite to go away and learn more. Now then, functions are a massive topic, and there's just no way that we can do them justice in this module. We'll honestly only be scraping the surface, but functions are massively important, so you'll want to listen hard, and you'll definitely want to play around with them as much as possible so that you really grok what we're learning here, okay? Because functions are like at the center of just about everything in Go. You ready? Alright, let's go bust some moves with functions.
Conditionals Okay, so now we're going to take a look at conditionals, or branching in Go. So, we'll be covering off good old if, and also Go's implementation of switch case. Our main objectives for this module being to learn how to use if and switch with Go. Now, if you're familiar with other programming languages, then obviously the principles in action here aren't going to be new to you, but what we will be doing is pointing out things specific to the way that Go uses them. So small, but important stuff, like where we place the curly braces, but also things like implicit breaking and how to implement fallthrough behavior, so plenty of good stuff to come. Alright then, let's kick on with if and switch.
Loops So in this module, we're going to look at loops in Go, and if you don't already know, you're probably going to like this. Go has only got one loop, the for loop. Now, okay, that could be a bit misleading, right? What we should probably say is Go has only got one command, or one keyword that's used for looping, the for command. But in Go, it's pretty flexible, so we can use it for infinite loops, we can use it to loop while a Boolean expression evaluates to true, so like what some other languages call a while loop, and we can use it to range over a list of values, let's say an array, or slice, or a map. So, while we've only got the for keyword for looping in Go, it is pretty flexible. Alright then, so, let's go have a real quick look at the syntax before taking a look at it in action.
Arrays and Slices Okay, so in this module, we're going to talk about arrays and slices, the idea being that by the end of the module, you'll have a decent grasp of what arrays and slices are and how to work with them in Go. Now, we're going to go about things like this. First up, we'll do a bit of theory on arrays and slices, basic stuff like what they are and how they're different. And you know what? We'll also see how slices are better and far more powerful than arrays. We'll also take a look at the syntax of how we declare them and how we work with them. Along the way, we'll look at some examples, so see how to implement them as code, and I also reckon along the way we'll take a look at how to do things like grow and shrink them, and probably a mention of multi-dimensional arrays and slices, basically arrays within arrays, and slices within slices. Well, that's the plan. First up then, let's go and see if we can explain the theory and the fundamentals.
Structs Alright then, so far in this course, we've looked at a bunch of different types supported in Go, so things like strings, ints, and floats, and more recently, arrays and slices and maps. And to be honest, right, with those in our arsenal, we'd probably be able to get most jobs done. But you know what? There's no doubt that there are times when, I don't know, more specialized types would be helpful. Well, that's exactly where structs come into play, and it's these structs that we'll be concentrating on in this module. So we'll go about the module like this. First up, we'll explain what a struct is, and at the same time, we'll give a brief mention to OO, Object Oriented programming from a Go perspective. Then, we'll look at how we work with structs, so defining them, declaring and initializing new variables based off of them, and then some basic ways of working with them and interacting with them. So, without further ado, let's go ahead and find out what a Go struct is.
What Next? Okay, so you've completed the course. A massive thanks from me for watching. I've really enjoyed teaching it. But a massive congrats to you, too, for completing it. I seriously hope that it hit the spot for you, and that you're already getting it on with Go, and ready to take things further. Well, if that is the case, we've got you covered here at Pluralsight. Just search our library for Go or golang; we'll be adding great new stuff all the time. But you know what, go and get involved with the community, too. There's tons of projects out there being written in Go. Get involved! But if you feel a bit new to it all, then I suggest you start by looking at some of the projects. Read through the code and read the comment threads and the likes, because looking at good code and reading through comment threads is a great way to learn to be a good Go coder. And you know what? If you keep playing with Go and following some of those projects, it's not going to be long before you're in a place where you can start contributing. Then, there's conferences and user groups. Check out your local user group, and if there's not one close by, what the heck? Why not go and set one up! And about the big conferences, so like Gophercon and. Go, and no doubt more in the future that are local to you. These are seriously good places to learn and network. And there's plenty more, too, but the thing is, Go is going places, and you can go wherever it's going. The future's bright, the future is Go.