Golang back-end development is very mature and easy to use. Several high-frequency libraries are summarized to quickly implement development.

Golang back-end development is very mature and easy to use, and several high-frequency libraries are summarized to quickly implement development.

Over time, many Go frameworks and libraries have been built and shared by language enthusiasts. These packages perform different functions, from developing microservices to making discord bots, all the way to building web applications! In this article, I will try to familiarize you with some useful methods that I have discovered while trying to learn and build applications in this interesting new programming language.


Static website generation
is a relatively new area for programming languages ​​commonly used to build backend APIs and microservices, so a bit of freshness is imminent.

hugo: A great package that lets you build static websites without backend interconnection, all written in Go. It also claims to be the fastest static web framework of its kind, with a load time of <1 millisecond per page and an average website build time of less than one second. It is designed to work with any type of website, including blogs and hosted documents. Best of all, you can host your static website on GitHub Pages for free too! Installing Hugo packages can be done via regular homebrew installation, Docker or even the go install command.

Working with configuration files
Configuration files are often written in various formats, such as JSON and YAML. Go has a very useful package that makes reading and writing various configuration file formats a breeze.

viper: This is a complete Go application configuration solution, including 12-Factor applications. It is designed to work within applications and can handle all types of configuration needs and formats.
Some of the neat features of this package include:

Reads from JSON, TOML, YAML, HCL, .env and Java property configuration formats.
Watch and reread profiles in real time.
Read from environment variables.


Command Line Interface
For building CLI applications, Go has a great library that makes it a breeze.

Cobra: A powerful library for creating Go-based CLI applications.
Some of the important features of this framework include:

It has powerful integration with the Viper library of profiles.
It supports regular subcommands, nested subcommands, and helps group similar commands.
Fully POSIX compliant logo (both short and long versions).


Environment Variables
Go has a number of packages that make it easier to read .env files that store various files that are considered application secrets. There is a great tool like this:

GoDotEnv: It has the simplest setup and usage for reading variables from .env files, and is also very lightweight to use.


Build Automation
Automation tools designed to help perform tasks through simple, concise commands. A popular tool that you may already know is the Make command, which helps us automate tasks using Makefiles. A good development practice is to keep a list of commands to be executed in a Makefile that we can easily reference later and execute using a simple make command.

taskfile: This library has more verbosity, so the interpretability of executing commands is slightly better than Make. It also has no dependencies and is very lightweight in comparison.


Active Compile
Air: This is a great utility Go package that helps rebuild and execute the project's main.go save or almost any saved file (as we wish) without us having to type it every time to run it .


Web Development
The following are popular web frameworks that are regularly maintained:

Gin Web Framework: This is the most popular Go web development library, and for many good reasons.
Iris: Another option for building high-performance web applications and APIs in Go. If you've used ExpressJS before, this will feel somewhat familiar to you.


Date Time Management
Carbon: This is a great lightweight, easy to use and semantically smart date time library for Go developers.


Database object relational management
Gorm: This is the easiest to use object relational mapping (ORM) Go library, especially suitable for the three mainstream databases SQLite, PostgreSQL and MySQL.
Xorm: XORM is a simple and powerful Go language ORM framework. It can make database operations very simple.


Microservices
Microservices are often used in containerized architectures with Docker and Kubernetes to build robust applications. Here are several Go microservice packages:

Echo: This framework supports RESTful API design and is the most popular Go microservice framework.
go-micro: This library is another great option in the same space, with built-in authentication and data storage design. Very convenient indeed.
go-zero: go-zero is a web and rpc framework that integrates various engineering practices


Bot
DiscordGo: This is the most useful API wrapper for Discord API functions with an excellent modular structure and contains all the major discord bot operations you may need.

One minor inconvenience is that it still doesn't have dedicated documentation, but I found during some experimentation of my own that it's very easy to read the code itself, as it's neatly divided into modules and packages.


Web Scraping
Colly: This is a great Go web scraper and crawler framework, especially useful for archiving (I've used it a lot) and data mining purposes.


Database related
Go-redis: This is a great, highly maintained redis database client for Go. It works with redis 6 and 7, and the setup process is very simple. highly recommended.
go-elasticsearch: This is the official Elasticsearch client for Go.
graphql-go: This is an implementation of GraphQL in Go, supporting queries, mutations, and subscriptions.

Guess you like

Origin blog.csdn.net/u014374009/article/details/133231465