Go Functions, Making Code Reusable

  We’ve been using functions right since we wrote our very first code, but we haven’t addressed what Go Functions are. In programming, a Function (sometimes called a subroutine) is a way of grouping code together so that we can reuse it in other parts of our program. When we want to use that group […]

Continue reading

Go fmt, the Go Style Guide

  A programming style guide is a description (formal or informal) of how a programmer should write code in a given language. So is there a Go style guide? Well, not exactly, but sort of. Instead of a style guide Go provides the Go fmt tool (not to be confused with the fmt package) instead. […]

Continue reading

Go Switch Statement, More Flow Control

  We’ve learned about for loops, and if/else if/else, now it’s time to introduce another flow control statement, the Go Switch. Most programming languages have a version of the Switch statement and Go is no exception. The Go Switch statement is functionally very similar to a big if/else if/else statement but can make your code […]

Continue reading

Go Range, Iterating Over Maps and Slices

So far when we’ve introduced Maps, Arrays, and Slices we’ve only talked about how to retrieve a single value from them at a time. While this is useful when we know a specific value to retrieve, it doesn’t help us if we want to do something with all of the values. In programming, the process […]

Continue reading

Go Map, The Key/Value Type

  In programming, the map, sometimes called a hash, a hash table, a dictionary, or an associative array is a data type that maps keys to associated values. You could think of a Go Map as a Rolodex or phone book. To find someone’s contact information you quickly look them up by name (the key) […]

Continue reading

The Go Array, What the Heck is a Slice?

  We covered the basic data types of Go when we learned about variables, so now it’s time to introduce a new kind of variable, the Go Array. In programming, an Array is an indexed ordered list of values. In our introduction to variables, we used the analogy of a post office P.O. box to […]

Continue reading

Go For Loop, Introduction to Loops

  Now that you’ve been introduced to flow control with if statements let’s move on to the Go for loop. The purpose of a loop is to execute a block of code some number of times or until/while some condition is true. Loops save us from needing to write the same code multiple times and […]

Continue reading

Go If Statement, Introduction to Flow Control

  So, now that we have an understanding of variables in Go let’s do something more interesting with them than just printing them out to the screen. So far all of the programs that we’ve written have been completely linear. They start at the top and line by line execute every statement in order unconditionally. […]

Continue reading

Variables in Go, What is a Variable?

  So before we talk about variables in Go specifically let’s make sure that we understand what a variable is. A variable has two parts, a name, and a location in the computer’s memory that holds a value. In programming, you can think of a variable like a P.O. box at the post office. The […]

Continue reading
>