Section 1 of 12

Go Basics & Setup

Get started with Go fundamentals and environment setup

Course Progress

Section 1 of 12

8% complete

Tutorials

Installation & Workspace

Go is an open-source programming language that makes it easy to build simple, reliable, and efficient software. ## Why Go? - **Simple syntax**: Easy to learn for developers from any background - **Fast compilation**: Compiles to native code - **Built for concurrency**: Goroutines make parallel programming easier - **Perfect for DevOps**: Used in Docker, Kubernetes, and many DevOps tools ## Installation 1. Download from golang.org 2. Follow platform-specific instructions 3. Verify with: go version

Code Examples

Hello Worldgo
package main

import "fmt"

func main() {
    fmt.Println("Hello, Go!")
}
Run Your Codebash
go run main.go
go build main.go
./main

Variables & Data Types

Go is a statically typed language. Understanding data types is crucial. ## Variable Declaration Go provides multiple ways to declare variables with flexibility and clarity.

Code Examples

Variable Declarationgo
package main

import "fmt"

func main() {
    // Explicit type declaration
    var name string = "Go Developer"
    var age int = 25
    var score float64 = 95.5
    
    // Short declaration (inside functions only)
    message := "Hello, Go!"
    count := 42
    
    // Multiple declarations
    var (
        city = "New York"
        country = "USA"
    )
    
    fmt.Println(name, age, score)
    fmt.Println(message, count)
}
Constantsgo
package main

import "fmt"

func main() {
    const PI float64 = 3.14159
    const COMPANY string = "MyCompany"
    
    // Multiple constants
    const (
        YEAR = 2024
        MONTH = "January"
    )
    
    fmt.Println(PI, COMPANY, YEAR)
}

Exercises

Create Variables

Create variables for your profile: name, age, email, and isActive (boolean)

BEGINNER

Starter Code:

package main

import "fmt"

func main() {
    // TODO: Declare your variables here
    
    fmt.Println(name, age, email, isActive)
}

Hands-on Project

Personal Profile Program

Create a program that displays your profile information with proper data types

BEGINNER

Learning Objectives

  • >Declare variables
  • >Use multiple data types
  • >Format output

Project Tips

  • > Start by understanding the requirements
  • > Break the project into smaller tasks
  • > Test your code frequently as you build
  • > Add error handling throughout your code
  • > Consider edge cases and validate inputs
  • > Document your code with comments