This is a beginner's GOlang project. I have written a program using which you can order food in a restaurant.
- Learn Go lang and build project as a beginner.
- Enhance Go skills and learnings by building project.
You should have basic knowledge of Go language like data types, if-else statement, loops, switch-statement, slices, maps and structures. If you don't know anything about Go language, then do checkout the resoruces section and you'll be good to go.
Want to order food!? Well, you have come to the right place(not exactly :P).
This is a program which will help you order food in a restaurant named "Jaipur Bhojanalya".
You can order any item that is there in the menu, and as many times as you want. This program also lets you modify your order by allowing you to update quantity of an item, add an item in the order or delete an item from the order; before generating the final bill.
- Golang basics
- Fmt (Printf and Scan)
- Variables and Data types
- Type Conversion
- String padding
- Conditionals(if/else)
- Switch Statement
- Arrays and Slices
- Maps
- Structs
There are several things that I learnt while building this project. I am sharing it, so that you can refer it if you get stuck.
-
How to append in a slice of struct?
Let say struct type name is NewStruct and we defined a new variable with the name a.
type NewStruct struct{ itemName string price uint quantity uint } //To append use the below code: a = append(a, NewStruct{itemName: name, price: bill, quantity: noOfPlates}
-
What happens when you loop through an string, slice, map?
Read for-loop range and unexpected values range to clear your doubts.
-
Time function : E.g.,
time.Now()
- Read this article to gain more insights.
-
Random function : E.g.,
randIntn(500)
,rand.Seed(time.Now().Unix())
;- Refer to this if you get stuck
-
Delete from a map :
delete(mapName, key)
Here are some screenshots of the program in running.