Go uses fmt.Println() for output. Every file starts with a package declaration.
Go
Learn concurrent programming with Go.
Hello World
Run this example to see how it works and then try the exercise.
Click "Run" to see the example in action...Your task: Print "Hello, World!" using fmt.Println()
Click "Run" to execute your code...What must every Go source file start with?
SUMMARY
In this section, you learned how to print output to the console. Next, you'll learn how to declare variables.
Variables
Go offers two ways to declare variables: var for explicit typing and := for short declaration.
Run this example to see how it works and then try the exercise.
Click "Run" to see the example in action...Your task: Declare variables name and age using :=
Click "Run" to execute your code...What is the short variable declaration operator in Go?
SUMMARY
In this section, you learned how to declare variables. Next, you'll learn how to perform mathematical operations.
Arithmetic Operations
Go supports all standard arithmetic operations. Integer division truncates the decimal part.
Run this example to see how it works and then try the exercise.
Click "Run" to see the example in action...Your task: Calculate area and print "Area: {area}"
Click "Run" to execute your code...What is the result of 17 / 5 in Go (both are int)?
SUMMARY
In this section, you learned how to perform mathematical operations. Next, you'll learn how to manipulate and work with strings.
Unlock 10 More Lessons
You've completed the free preview! Upgrade to Pro to access all 12 lessons in this course, plus advanced projects and certificates.
- String Operations
- Functions
- Conditionals
- Switch Statements
- Arrays and Slices
- Maps
- Structs
- Structs
- Final Project: Student Grade System