Syntax, packages and tools
Go favours a small grammar and one obvious formatting style.
What you will be able to do
- Run gofmt on every file; there is no style negotiation.
- Keep package names short and lowercase.
- Use := inside functions and var at package scope.
In plain English
Go programs are made of packages. Exported identifiers start with a capital letter. gofmt removes formatting debates; go test runs tests beside the code. Compile errors are part of the feedback loop.
package main
import "fmt"
type Course struct {
Slug string
Lessons int
}
func main() {
course := Course{Slug: "go", Lessons: 5}
fmt.Printf("%s has %d lessons\n", course.Slug, course.Lessons)
}Your turn
EasyDefine a lesson
Create a Lesson struct with Title and Minutes, then print both fields.
GO · starter
type Lesson struct {
}Check your understanding before moving on.
Knowledge checkQuestion 1
What does an exported Go identifier start with?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.