Skip ke Konten

Project 1: Getting Started

Simple Web Server with Golang

Hello there! My name is Azriel and I'm excited to share with you my journey of learning Golang or Go programming language. As someone who's always been interested in coding and software development, I've decided to take on the challenge of mastering this new language.

But things to note here, this is my first time writing some blog, or any content actually, and English is not my first language, so bear with me. I know this won't be easy, but I believe that by documenting my progress and publishing it, I'll be able to learn even faster and more effectively.



Why Golang?

Well first I wanted to learn a new programming language to add to my skill but I didn't have anything in mind, so I narrowed it down to what skills I already have which is backend development with Node.JS and Python, then I search it up what suited my need.

And just like that, I knew Golang is one of the top programming languages in backend development, and relatively new but has rapid growth, so that is the main reason why I choose to learn Golang. I also read about how fast Golang run, compiles faster, and is easy to maintain, but that are just additional reasons for me.

Installation

The one thing that needs to be done first before starting to code is to install Golang on my computer. I am using Windows with Golang version 1.20.3, just follow the step from the official Golang website here https://go.dev/doc/install.

Use the command go version on the terminal to check if the Golang is already installed.

Learning Reference

Since I'm already pretty familiar (and confident) that I already familiar with the syntax of multiple programming languages so I skip the part where I learn basic syntax on Golang and jump through the implementation. I will use a free tutorial from CodeCamp on Youtube here.

The tutorial will have 11 project which is:

  1. Simple Web Server
  2. CRUD API
  3. YSQL Book Management System
  4. SlackBot to Calculate Age
  5. Slackbot for File Uploading
  6. Email Verifier Tool
  7. AWS Lambda
  8. CRM Fiber
  9. HRMS Fiber
  10. Complete serverless stack
  11. AI Bot with wolfram and wit.ai

My goal is each day I will progress with one project, and after that, I will start creating my own project from scratch. I will upload my progress source code to my GitHub here.

Also for convenience, I use some of VSCode extensions (the perks of using VSCode as an editor) like official go extension, vscode-go-syntax, and go doc. For preference and entertainment, I also use vscode-pets.






Simple Web Server

So basically I created a web server using Golang, but I already learn a lot since this is my first Golang project. I learn how to initiate a Golang project using go mod init {project-nameand using go run {file-name} to run the code which the youtube tutorial fails to mention at the beginning so I need to search for it by myself.

The Golang file also must start with declaring the package that the file will go to, so the first line must be package {package-name}. I also learn how to import packages and the need for functions named main, basically just like C++.

This first project is not containing the MVC structure (the route, controller, and model on a separate file), so just a simple web server in one file. In this project, I learn how to serve a server on some ports using http package, I also learn how to create a route and handling function. In this project also I learn how to get data from a form in a static website and also return it to the page as a response. There is also a small learning step like using fmt package to print something on the console or write some string to the response object.

Below is the file structure of the project.

Folder static is for the static website written in HTML, and the go.mod is for the information of the project and the package that is used, just like package.json in Node.JS, and finally the main.go file is where the server code is.


Excitingly, I'm planning to take the next step by incorporating the powerful Gorilla Mux framework to efficiently handle routes and perform CRUD operations on structured data. Stay tuned for the latest updates on my progress!



Project 5: Email Validator
Email regex and domain checker