Improve your Golang skill by rewriting popular software
Tags: go, programming, tutorial
Published: 2022-07-19 16:01:07

The fastest way to learn is to learn by doing. If you are unsure what to do to improve your skills and knowledge of the Golang language, then in this article I will introduce some documents that show you how to rewrite popular software that uses Golang.

![Golang](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ym7biiz6l359ejuy08l2.png)

These tutorials come from the Github repository [Build Your Own X](https://github.com/codecrafters-io/build-your-own-x). A popular and useful Github repository.

## Build BitTorrent Client
From Wikipedia:

> BitTorrent is a communication protocol for peer-to-peer file sharing, which enables users to distribute data and electronic files over the Internet in a decentralized manner.

This tutorial below will help you write your BitTorrent software using the Golang language.

[Building a BitTorrent client from the ground up in Go](https://blog.jse.li/posts/torrent/).

![BitTorrent](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zm6lgccb1sf6pgn01w5g.png)

## Build Blockchain/Cryptocurrency
Blockchain is probably not new if we know about cryptocurrency, this has been a scorching topic in recent years. Below is a tutorial series on how to build blockchain using Go.

[Building Blockchain in Go](https://jeiwan.net/).

![Blockchain](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/27r1x9uhx985pl14dxm7.png)

## Build Command-Line Tool
Next, these tutorials on building CLI tools, when writing CLI tools we will have a better understanding of the operating system. Here are four tutorials that show you how to build four different CLI tools.

[Visualize your local git contributions with Go](https://flaviocopes.com/go-git-contributions/).

[Build a command line app with Go: lolcat](https://flaviocopes.com/go-tutorial-lolcat/).

[Building a CLI command with Go: cowsay](https://flaviocopes.com/go-tutorial-cowsay/).

[Go CLI tutorial: fortune clone](https://flaviocopes.com/go-tutorial-fortune/).

![Visualize your local git](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xwpj164hi6wg8x8hvr9y.png)

## Build Container
The tutorial on how to write your Container Runtime with Go is the best I've read, in this article, the author will explain to us how Containers work, and how to use Golang to build it, this post is great. This is the article that will help you somewhat become more understanding of the Golang language and how Linux OS works. Thank Julian Friedman and Liz Rice.

[Build Your Container Using Less than 100 Lines of Go](https://www.infoq.com/articles/build-a-container-golang/).

[Building a container from scratch in Go - Video](https://www.youtube.com/watch?v=8fi7uSYlOdc).

![Building a container](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jni4lqbneepdqpy3kjv7.png)

## Build Game
Have you ever thought that Golang can be used to write Games? If not, this article will guide you.

[Games With Go - Video](https://www.youtube.com/watch?v=9D4yH7e_ea8).

![Games With Go](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/drtwdydqme76cnu55x0c.png)

## Build Neural Network
If you do AI, you must know Neural Network (I don't know it 😂). Maybe, we often write an AI Model in Python, if you want to challenge yourself, try to build an AI Model with Go.

[Build a multilayer perceptron with Golang](https://made2591.github.io/posts/neuralnetwork).

[How to build a simple artificial neural network with Go](https://sausheong.github.io/posts/how-to-build-a-simple-artificial-neural-network-with-go/).

[Building a Neural Net from Scratch in Go](https://datadan.io/blog/neural-net-with-go).

![Neural Network](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ey0vg15lxnh5guhbpk0r.png)

## Build Shell
The simplest explanation of the shell is a program that takes commands from the keyboard and gives them to the operating system to perform. The below article will guide you on how to write your shell interface using Go, after reading you will have a better understanding of how the shell works.

[Writing a simple shell in Go](https://sj14.gitlab.io/post/2018/07-01-go-unix-shell/).

In this tutorial, Simon Jürgensmeyer will show you how to re-code a simple shell in less than 80 lines of code.

```go
package main

import (
	"bufio"
	"errors"
	"fmt"
	"os"
	"os/exec"
	"os/user"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	for {
		path, err := os.Getwd()
		if err != nil {
			fmt.Fprintln(os.Stderr, err)
		}

		hostname, err := os.Hostname()
		if err != nil {
			fmt.Fprintln(os.Stderr, err)
		}

		currentUser, err := user.Current()
		if err != nil {
			fmt.Fprintln(os.Stderr, err)
		}

		path = strings.Replace(path, "/home/"+currentUser.Username+"", "~", -1)

		fmt.Printf("%s@%s:%s$ ", currentUser.Username, hostname, path)

		// Read the keyboad input.
		input, err := reader.ReadString('\n')
		if err != nil {
			fmt.Fprintln(os.Stderr, err)
		}

		if err := execInput(input); err != nil {
			fmt.Fprintln(os.Stderr, err)
		}
	}
}

func execInput(input string) error {
	input = strings.TrimSuffix(input, "\n")

	args := strings.Split(input, " ")

	switch args[0] {
	case "cd":
		if len(args) < 2 {
			return errors.New("path required")
		}

		return os.Chdir(args[1])
	case "exit":
		os.Exit(0)
	}

	cmd := exec.Command(args[0], args[1:]...)

	cmd.Stderr = os.Stderr
	cmd.Stdout = os.Stdout

	return cmd.Run()
}
```

## Build Load Balancer
Load Balancer is probably no stranger to you guys working on the server. Load balancer acts as the traffic division sitting in front of your servers and routing client requests across all servers. Writing your Load Balancer will help you better understand a lot of knowledge about the LB. This is a tutorial on how to build a Load Balancer by yourself using Go.

[Let's Create a Simple Load Balancer](https://kasvith.me/posts/lets-create-a-simple-lb-go/).

![Create a Simple Load Balancer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ro05jw96fcv5ttru5td5.png)

## Conclusion
In this article, I just want to introduce you to useful resources for learning and improving my skills, many of the above articles I have not read yet 😁. In addition to Go, in the Github repository I introduced above, there are many other good articles written in different languages, please go and see, very useful for you.