Basic Data Types
Get familiar with Go’s fundamental data types and literals.Print Literals
Print Literals
Objective: Practice using different literal typesPrint various values using int, float, string, and bool literals.Key Concepts:
- Integer literals
- Float literals
- String literals
- Boolean literals
- Literal syntax
Print Hexadecimal Numbers
Print Hexadecimal Numbers
Objective: Learn alternative number representationsPrint numbers using hexadecimal notation.Key Concepts:
- Hexadecimal literals (0x prefix)
- Number base representations
- Printf formatting
Variable Declarations
Practice the standard variable declaration syntax with thevar keyword.
Declare Int Variables
Declare Int Variables
Objective: Declare and use integer variablesDeclare int variables using the
var keyword.Approach:Declare Bool Variables
Declare Bool Variables
Objective: Work with boolean variablesDeclare and initialize boolean variables.Approach:
Declare Float64 Variables
Declare Float64 Variables
Objective: Handle floating-point numbersDeclare and use float64 variables for decimal numbers.Approach:
Declare String Variables
Declare String Variables
Objective: Work with text dataDeclare and manipulate string variables.Approach:
Undeclarable Types
Undeclarable Types
Objective: Understand what cannot be declared with varTry to declare variables with invalid type specifications.Key Concepts:
- Valid vs invalid type names
- Compiler error messages
- Type system rules
Declare with Bits
Declare with Bits
Objective: Learn about sized integer typesUse specific integer types like int8, int16, int32, int64.Approach:
Multiple Declarations
Multiple Declarations
Objective: Declare multiple variables efficientlyLearn different ways to declare multiple variables.Approach:
Package-Level Variables
Package-Level Variables
Objective: Understand package scopeDeclare variables outside of functions at the package level.Key Concepts:
- Package-level scope
- Initialization order
- Global state
main() and access them within functions.Short Declaration
Master the:= operator for concise variable declarations.
Short Declaration Syntax
Short Declaration Syntax
Objective: Use the := operatorPractice the short declaration operator for local variables.Key Concepts:
- Type inference
- Local scope only
- Simultaneous declaration and assignment
Multiple Short Declarations
Multiple Short Declarations
Objective: Declare multiple variables with :=Declare and initialize multiple variables in one statement.Approach:
Short Declaration with Expressions
Short Declaration with Expressions
Objective: Use expressions in short declarationsAssign the result of expressions to variables using :=.Approach:
Discard with Underscore
Discard with Underscore
Objective: Use the blank identifierDiscard unwanted return values using
_.Key Concepts:- Blank identifier
_ - Discarding values
- Multiple return values
Redeclaration
Redeclaration
Objective: Understand redeclaration rulesLearn when you can redeclare variables with :=.Key Concepts:
- At least one new variable required
- Redeclaration vs reassignment
- Scope rules
Assignment and Type Conversion
Learn to work with variable assignments and convert between types.Variable Assignment
Variable Assignment
Objective: Reassign variable valuesPractice assigning new values to existing variables.Approach:
Assignment with Expressions
Assignment with Expressions
Objective: Use expressions in assignmentsAssign calculated values to variables.Approach:
Calculate Rectangle Perimeter
Calculate Rectangle Perimeter
Objective: Apply variables to solve a problemCalculate and print the perimeter of a rectangle.Approach:
- Declare width and height
- Calculate perimeter:
2 * (width + height) - Print the result
Multiple Assignment
Multiple Assignment
Objective: Assign to multiple variables simultaneouslyUse parallel assignment for multiple variables.Approach:
Swapper
Swapper
Objective: Swap variable valuesExchange the values of two variables.Approach:
Type Conversion Basics
Type Conversion Basics
Objective: Convert between numeric typesPractice explicit type conversion in Go.Key Concepts:
- Explicit conversion required
- No implicit conversions
- Syntax:
Type(value)
Fix Type Conversion Errors
Fix Type Conversion Errors
Objective: Debug type mismatch issuesFix programs with type conversion errors.Approach:
- Identify type mismatches
- Add explicit conversions
- Ensure conversions are safe
Command-Line Arguments
Work with command-line input usingos.Args.
Count Arguments
Count Arguments
Objective: Access command-line argumentsCount and print the number of arguments passed to your program.Key Concepts:
os.Argsslice- Argument indexing
- Program name in Args[0]
Print the Path
Print the Path
Objective: Access the program pathPrint the path of the running program.Approach:
Print Your Name
Print Your Name
Objective: Use command-line argumentsAccept and print a name from command-line arguments.Approach:
- Check if argument exists
- Access
os.Args[1] - Print the value
Greet Multiple People
Greet Multiple People
Objective: Process multiple argumentsGreet each person passed as a command-line argument.Approach:
Loop through
os.Args[1:] and greet each person.Next Steps
Control Flow
Learn conditionals and loops
Data Structures
Work with arrays, slices, and maps