Unit Testing in Golang

Unit testing is a software testing technique in which individual units (smallest testable parts) of a software application are tested in isolation from the rest of the application. The goal of unit testing is to validate that each unit of the application is working as intended and meets the specified requirements. In Go, the testing package provides support for writing unit tests. To write unit tests, you need to create a file with a name that ends in _test.go and place it in the same package as the code you want to test. The testing package also provides a testing.T type that represents a testing context and has methods for reporting test failures and logging messages. ...

January 9, 2023 · 3 min · 634 words

What Is the Difference Between Git Pull and Git Fetch

Git is a version control system that is widely used in software development to track and manage changes to source code. Two of the most common Git commands that developers use to retrieve updates from a remote repository are git pull and git fetch. While these two commands may seem similar at first glance, they have some important differences that are worth understanding. The git pull command is a combination of git fetch and git merge. When you run git pull, Git first retrieves the latest version of the repository from the remote server. It then merges the changes into your local copy of the repository. This means that git pull not only downloads the changes from the remote repository, but it also integrates them into your local copy. ...

January 8, 2023 · 2 min · 412 words

Streaming Video With Golang

Streaming video with Go (Golang) is a popular choice for building efficient and scalable video streaming applications. In this blog post, we’ll discuss some of the key concepts and considerations for building a video streaming application with Go. One of the first things to consider when building a video streaming application is the underlying video format. Go has built-in support for working with a variety of video formats, including MP4, FLV, and AVI. However, the most common format for streaming video is probably H.264, which is a popular choice due to its high compression ratio and wide compatibility with a variety of devices and platforms. ...

January 4, 2023 · 5 min · 1063 words

Use Protobuf With Fastapi

Protocol buffers, also known as Protobuf, are a popular data serialization format used for communication between services. They are efficient, easy to use, and language-agnostic. In this article, we will look at how to use Protobuf with FastAPI, a modern, high-performance web framework for building APIs with Python. First, let’s start by installing the necessary dependencies. You will need to install fastapi, google-protobuf, and grpcio. You can do this by running the following command: ...

January 4, 2023 · 2 min · 374 words

The Context Package

Context in Go is a type that carries a request-scoped value across API boundaries. It is designed to be used in long-lived requests, such as an HTTP server handling multiple requests over the lifetime of a process. One of the primary use cases of context is to cancel long-running operations. For example, if an HTTP server receives a request with a cancelation token, it can use that token to cancel the request if the client closes the connection. This helps to avoid resource leaks by freeing up resources that would have been used by the request. ...

January 3, 2023 · 4 min · 771 words