We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Formatting

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!")
}

go fmt

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.

Assignment

func main() {
vs
func main(){

Run and submit the CLI tests from the root of your repo.