

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Formatting
incomplete
2: Check Formatting
incomplete
3: Formatting CI
incomplete
This lesson's interactive features are locked, please to keep using them
Automated code formatting keeps your code consistent and readable. It's also a great way to avoid arguments about code style (bikeshedding).
I almost never start a new project without enforcing automated code formatting.
For example, this is technically valid:
func main() {
fmt.Println("hello world!") }
But it's not formatted according to standard conventions. You would normally write it like this:
func main() {
fmt.Println("hello world!")
}
The go fmt command formats Go code. It's built into the Go toolchain, so you don't need to install anything additional to use it.
I have configured my editor to auto-format my code on save, so my code is always formatted. The default "Notely" project should already be formatted properly, so let's break it so that we can see how go fmt works.
func main() {
vs
func main(){
Run and submit the CLI tests from the root of your repo.