Go Programming — Full Course
From your first program to goroutines and channels — the language behind Docker, Kubernetes, and modern cloud infrastructure.
From your first program to goroutines and channels — the language behind Docker, Kubernetes, and modern cloud infrastructure.
Go (often called Golang to make it easier to search for) was created at Google in 2007 and released publicly in 2009, designed by a team that included Ken Thompson, one of the original creators of Unix and the C language. Go was built as a deliberate reaction to the complexity of languages like C++ […]
var age int = 25nvar price float64 = 19.99nname := “Tutoline” // short declaration — type is inferrednisActive := true Go is statically typed like Java or C++, but the := short declaration operator infers the type automatically, similar in feel to auto in C++ or var in JavaScript — you will use := for […]
if statements score := 82nif score >= 90 {n fmt.Println(“A”)n} else if score >= 75 {n fmt.Println(“B”)n} else {n fmt.Println(“C”)n} Notice there are no parentheses around the condition — Go deliberately drops them, and the braces are required even for a single-line body, unlike C or Java where they are optional. This is a small […]
Arrays and slices var fixedArray [3]string = [3]string{“a”, “b”, “c”} // fixed size, rarely used directlynncourses := []string{“Go”, “Python”, “SQL”} // a slice — resizable, used constantlyncourses = append(courses, “TypeScript”)nfmt.Println(courses[0]) // Gonfmt.Println(len(courses)) // 4 A slice is a resizable, flexible view over an underlying array, and is what real Go code uses for lists almost […]
Pointers, simplified score := 90nscorePtr := &score // scorePtr holds the memory address of scorenfmt.Println(*scorePtr) // dereference: 90n*scorePtr = 95nfmt.Println(score) // 95 — changed through the pointer Go has pointers, using the same & (address-of) and * (dereference) syntax as C++, covered in that course’s functions and pointers lesson. Go’s version is deliberately simpler, though […]
This is Go’s signature feature, and the main reason many teams choose it for backend services: running many things concurrently is genuinely easy, not an advanced topic bolted on afterward like in many other languages. Goroutines func sayHello() {n fmt.Println(“Hello from a goroutine”)n}nnfunc main() {n go sayHello() // runs concurrently, doesn’t blockn time.Sleep(100 * time.Millisecond) […]
Errors as values func divide(a, b float64) (float64, error) {n if b == 0 {n return 0, fmt.Errorf(“cannot divide by zero”)n }n return a / b, niln}nnresult, err := divide(10, 0)nif err != nil {n fmt.Println(“Error:”, err)n returnn}nfmt.Println(result) Go has no exceptions in the sense Python, Java, or JavaScript do. Instead, a function that might […]