Code
Create main.go — your fields become variables
Replace the contents of your main.go with this (the sample continues the book-list thread from lesson 1; your fields will differ). All three forms in one place:
const appName— at file level: the app's name never changes.var title string = ...— the full form with an explicit type.pages := 380andread := false— the short form; Go infersintandbool.
The new thing is fmt.Printf with format verbs: %s inserts text, %d an integer, %v anything (handiest for bool). The \n at the end is a newline.
Verify.
go run main.go
You must see exactly:
App: Book list
Book: The Go Programming Language | pages: 380 | read: false
Tip. Try to break it: inside the function write
pages := "many"afterpagesis already anint— the compiler refuses. Go types are fixed: born a number, stays a number.