DEV Community

Cover image for Improve your Golang skill by rewriting popular software
DevOps VN
DevOps VN

Posted on

Improve your Golang skill by rewriting popular software

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

These tutorials come from the Github repository 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.

BitTorrent

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.

Blockchain

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.

Build a command line app with Go: lolcat.

Building a CLI command with Go: cowsay.

Go CLI tutorial: fortune clone.

Visualize your local git

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.

Building a container from scratch in Go - Video.

Building a container

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.

Games With Go

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.

How to build a simple artificial neural network with Go.

Building a Neural Net from Scratch in Go.

Neural Network

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.

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

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()
}
Enter fullscreen mode Exit fullscreen mode

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.

Create a Simple Load Balancer

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.

Oldest comments (0)