GO

Go Fundamentals

18 lessons

Progress0%
1. Introduction to Go
1What is Go?
2. Variables and Data Types
1Data Types in Go
3. Control Flow
If, For, and SwitchDefer, Panic, Recover
4. Functions
Function BasicsError Handling
5. Structs and Methods
StructsMethods and Interfaces
6. Concurrency
Goroutines and ChannelsSelect and Sync
7. Maps & Slices Advanced
Slices Deep DiveMaps Operations & Patterns
8. Interfaces Deep Dive
Interface Composition & anyCommon Interfaces & Patterns
9. Packages & Modules
Package SystemGo Modules & Workspace
10. Testing & Standard Library
Testing in GoStandard Library Essentials
All Tutorials
GoIntroduction to Go
Lesson 1 of 18 min
Chapter 1 · Lesson 1

What is Go?

Go (also called Golang) is an open-source programming language developed by Google. Created by Robert Griesemer, Rob Pike, and Ken Thompson, it was designed for simplicity, efficiency, and ease of use in modern software development.

Key Features:

  • Simple Syntax: Easy to learn and read
  • Fast Compilation: Compiles to native machine code
  • Built-in Concurrency: Goroutines and channels
  • Garbage Collected: Automatic memory management
  • Strong Standard Library: Excellent networking, HTTP, JSON support

Where Go is Used:

  • Cloud services (Docker, Kubernetes)
  • Web backends and APIs
  • Command-line tools
  • DevOps and infrastructure
  • Microservices

Go's Philosophy:

  • Simplicity over cleverness
  • One way to do things
  • Explicit over implicit
  • Composition over inheritance

Code Examples

Hello Worldgo
package main

import "fmt"

func main() {
    // Print to console
    fmt.Println("Hello, World!")
    
    // Variables
    var name string = "Go"
    version := 1.21  // Short declaration with type inference
    
    fmt.Printf("Welcome to %s %.2f!\n", name, version)
    
    // Multiple return values (common in Go)
    result, err := divide(10, 2)
    if err != nil {
        fmt.Println("Error:", err)
    } else {
        fmt.Println("Result:", result)
    }
}

func divide(a, b float64) (float64, error) {
    if b == 0 {
        return 0, fmt.Errorf("cannot divide by zero")
    }
    return a / b, nil
}

Go emphasizes simplicity. Note the := for short variable declaration and multiple return values for error handling.

Quick Quiz

1. What does := do in Go?

Was this lesson helpful?

OverviewNext