Lab · Go Programming (backend and cloud)
Lab: a bill printer for a chai stall
The brief
Sharma Chai Stall near a college gate wants a tiny program on its counter laptop that prints the bill. You install Go, create a module, then build the bill up line by line: the shop name, each item with its total, and the GST with two decimals.
Why it matters
Every Go job starts the same way: a working toolchain, a module with go.mod, and a main package you can run. Small billing and report programs like this are also how many shops and offices first use Go, because go build gives one file that runs on the counter laptop without Go installed.
Skills you practise
- go version and go mod init
- package main and func main
- fmt.Println and fmt.Printf verbs
- variables and :=
- constants
- float64() and strconv.Atoi
You need
- Go 1.22 or newer installed from go.dev/dl (the course uses the latest, such as Go 1.26)
- A terminal: PowerShell or Windows Terminal on Windows, Terminal on macOS or Linux
- An editor with Go support, for example VS Code with the Go extension
What you will have at the end
A Go module example.com/chaistall whose go run . prints a correct chai stall bill with GST, and a built binary for the counter laptop.
How it is marked (rubric, 100 points)
| Toolchain and modulego version works, and go.mod names example.com/chaistall. | 20 |
|---|---|
| Correct billEvery line matches: Rs 45, Rs 40, subtotal Rs 85, GST Rs 4.25, total Rs 89.25. | 40 |
| Idiomatic codeConstants for fixed values, := for variables, an explicit float64 conversion, the Atoi error checked, gofmt and go vet clean. | 25 |
| ExplainedYou can say why 85 * 5 / 100 in int maths gives 4, and what float64() changes. | 15 |
0/5 steps done
Step 1 of 5
Check that Go is installed
go version prints the installed Go version and your system.
Install Go from go.dev/dl with the default settings, then close and reopen your terminal so it picks up the new PATH (the list of folders your terminal searches for commands). go version prints the version and the operating system/processor pair, such as windows/amd64 or linux/arm64. Paste the whole line.
$ go versionAlso check yourself
Your notes: main.go
Write down each command you ran. It goes into your project summary.