The Single Responsibility Principle

The Single Responsibility Principle (SRP) is a software design principle that states that a software module or component should have only one reason to change. This means that a module or component should have a single, narrowly defined responsibility and all of its features should be related to that responsibility. In Go, the SRP can be applied at both the package and the function level. At the package level, it’s important to consider what a package should be responsible for. A package should contain all of the code related to a specific feature or set of features. For example, a package that handles user authentication and authorization should not also contain code related to sending email notifications. These are two distinct responsibilities and should be separated into different packages. ...

March 21, 2023 · 2 min · 377 words

Schedule Github Action With Cron

Cron scheduling is a useful feature in GitHub Actions that allows you to run a workflow on a schedule. This can be useful for tasks such as running tests or deploying code at regular intervals. To use cron scheduling in GitHub Actions, you will need to add a schedule key to your workflow file. The schedule key should contain a cron expression that specifies when the workflow should run. Here is an example of a workflow that runs every day at noon: ...

March 12, 2023 · 2 min · 407 words

How to Delete Git Branch Locally

To delete a Git branch locally, you can use the git branch command with the -d flag, followed by the name of the branch you want to delete. For example: git branch -d branch_name This will delete the specified branch if it has already been fully merged into the current branch. If the branch has not been fully merged, you can use the -D flag instead, which will force the deletion of the branch. ...

March 7, 2023 · 1 min · 193 words

How to Undo Most Recent Local Git Commit

Git is a version control system that allows developers to track changes to their codebase and collaborate with others. One of the useful features of Git is the ability to revert changes that have been made to the codebase. In this article, we will look at how to undo the most recent local commits in Git. There are several ways to undo commits in Git, and the method you choose will depend on your specific needs. Here are three common ways to undo commits in Git: ...

February 28, 2023 · 2 min · 378 words

Implement Desing Patterns With Golang

Design patterns are reusable solutions to common software design problems. They are a way to structure and organize code in a way that makes it easier to understand, maintain, and extend. In this article, we’ll explore how to implement some popular design patterns in Go. Singleton pattern The singleton pattern is a creational design pattern that ensures a class has only one instance and provides a global access point to it. In Go, we can implement the singleton pattern using the sync.Once type. Here’s an example: ...

February 21, 2023 · 4 min · 799 words