Go was designed at Google in 2007 to improve programming productivity in an era of multicore, networked machines and large code bases.The designers wanted to address criticism of other languages in use at Google, but keep their useful characteristics.
During past couple of days I have been learning Golang and I noticed some of the challenges I faced was the lack of constraints or standards, choosing external packages and much more😭. I would like to share some findings that have worked for me and also walk you through the steps by building a simple todo app.
- A Golang compiler installed on your Machine
- An IDE or text editor
- Basic understanding of Go
- Basic understanding of HTML and CSS
- Basic understanding of SQL (Only required to create Database 😉)
We would start by creating a module for our project so as to better track our packages in a file called
go.mod which would makes it easier for distribution or deployment. it's more like
go mod init github.com/iamhabbeboy/todoapp
Next, we need to create the following folders.
You don't have to follow this structure.😊
todoapp ├──models | └── Todo.go ├── controllers | └── TodoController.go ├── database | └── connect.go ├── views | └── index.html | └── create.html |── main.go |── .env
The following packages would be used to better develop our project.
- Gorm: Go ORM that support mysql and other databases.
go get -u github.com/jinzhu/gorm
- Mux: It's handles our routes and requests.
go get -u github.com/gorilla/mux
- Godotenv: Would be used to access our
go get github.com/joho/godotenv
- MySQL driver: Allow connection to MySQL DB
go get github.com/go-sql-driver/mysql
I wouldn't want you to be bored with this post so I decided to split it into two. The other part would be posted in the comment section soon.
Please do leave a comment in case you have any contributions, I would really appreciate that.😉
Thanks for reading.❤️