GO

Go每日一库之105:juju%2Fratelimit

限流又称为流量控制(流控),通常是指限制到达系统的并发请求数,常用的限流算法主要有漏洞和令牌桶。 ### 令牌桶 令牌桶其实和漏桶的原理类似,令牌桶按固定的速率往桶里放入令牌,并且只要能从桶里取出令牌就能通过,令牌桶支持突发流量的快速处理。 ![每日一库之105:juju%2Fratelimit-0 ......
2Fratelimit Fratelimit juju 105

Go每日一库之69:resty

## 简介 [`resty`](https://github.com/go-resty/resty)是 Go 语言的一个 HTTP client 库。`resty`功能强大,特性丰富。它支持几乎所有的 HTTP 方法(GET/POST/PUT/DELETE/OPTION/HEAD/PATCH等),并 ......
resty

Go每日一库之70:termtables

## 简介 今天学个简单点的,[`termtables`](github.com/scylladb/termtables)处理表格形式数据的输出。适用于随时随地的输出一些状态或统计数据,便于观察和调试。是一个很小巧的工具库。我在学习[`dateparse`](https://go-quiz.gith ......
termtables

Go每日一库之85:freecache

# [freecache](https://github.com/coocood/freecache) ## 一句话描述 Go缓存库,具有零GC开销和高并发性能 ## 简介 ### freecache是什么? 使用FreeCache,您可以在内存中缓存无限数量的对象,而不会增加延迟和降低吞吐量。 # ......
freecache

Go每日一库之86:zerolog

## [zerolog](https://github.com/rs/zerolog) ## 什么是 Zerolog ? zerolog 包提供了一个专门用于 JSON 输出的简单快速的Logger。 zerolog 的 API 旨在为开发者提供出色的体验和令人惊叹的[性能](https://git ......
zerolog

Go每日一库之87:zap

## [⚡ZAP](https://github.com/uber-go/zap) ## 简介 ### zap 是什么? [⚡ZAP](https://github.com/uber-go/zap) 是uber 开源的提供快速,结构化,高性能的日志记录包。 ### zap 高性能体现在哪里? 在介绍 ......
zap

Go每日一库之73:gorilla-mux

## 简介 [`gorilla/mux`](https://github.com/gorilla/mux)是 gorilla Web 开发工具包中的路由管理库。gorilla Web 开发包是 Go 语言中辅助开发 Web 服务器的工具包。它包括 Web 服务器开发的各个方面,有表单数据处理包[`g ......
gorilla-mux gorilla mux

Go每日一库之74:gorilla-handlers

## 简介 上一篇文章中,我们介绍了 gorilla web 开发工具包中的路由管理库[`gorilla/mux`](https://github.com/gorilla/mux),在文章最后我们介绍了如何使用中间件处理通用的逻辑。在日常 Go Web 开发中,开发者遇到了很多相同的中间件需求,[g ......
gorilla-handlers handlers gorilla

Go每日一库之75:gorilla-schema

## 简介 [`gorilla/schema`](https://github.com/gorilla/schema) 是 gorilla 开发工具包中用于处理表单的库。它提供了一个简单的方式,可以很方便地将表单数据转为结构体对象,或者将结构体对象转为表单数据。 ## 快速使用 本文代码使用 Go ......
gorilla-schema gorilla schema

Go每日一库之72:net-http(基础和中间件)

## 简介 几乎所有的编程语言都以`Hello World`作为入门程序的示例,其中有一部分以编写一个 Web 服务器作为实战案例的开始。每种编程语言都有很多用于编写 Web 服务器的库,或以标准库,或通过第三方库的方式提供。Go 语言也不例外。本文及后续的文章就去探索 Go 语言中的各个Web 编 ......
中间件 net-http 基础 http net

Go - Using Log Levels

Examples of log levels from high to low are: • Fatal • Error• Warn • Info • Debug To set up log levels for your logs, you can add the level to each li ......
Levels Using Log Go

Go - Logging to File

Problem: You want to log events to a logfile instead of standard error. Solution: Use the SetOutput function to set the log to write to a file. You us ......
Logging File Go to

Go - Change What Is Being Logged by the Standard Logger

Problem: You want to change what the standard logger logs. Solution: Use the SetFlags function to set flags and add fields to each log line. The defau ......
Standard Change Logged Logger Being

Go - logging

The log package provides several functions that allow you to write logs. In particular, there are three sets of functions:Print • Prints the logs to t ......
logging Go

Go - Inspecting Errors

Problem: You want to check for specific errors or specific types of errors. Solution: Use the errors.Is and errors.As functions. The errors.Is functio ......
Inspecting Errors Go

Go - Wrapping an Error with Other Errors

Problem: You want to provide additional information and context to an error you receive before returning it as another error. Solution: Wrap the error ......
Wrapping Errors Error Other with

Go - Creating Customized Errors

Problem: You want to create custom errors to communicate more information about the error encountered. Solution: Create a new string - based error or ......
Customized Creating Errors Go

Go - Simplifying Repetitive Error Handling

Problem: You want to reduce the number of lines of repetitive error - handling code. Solution: Use helper functions to reduce the number of lines of r ......
Simplifying Repetitive Handling Error Go

Go - Using Multiple Versions of the Same Dependent Packages

Problem: You want to use multiple versions of the same dependent packages in your code. Solution: Use the replace directive in the go.mod file to rena ......
Dependent Multiple Packages Versions Using

Go - Requiring Local Versions of Dependent Packages

Problem: You want to use local versions of the dependent packages. Solution: Set up Go to use a vendor directory by running go mod vendor. Local versi ......
Dependent Requiring Packages Versions Local

Go每日一库之33:go-app

## 简介 [`go-app`](https://github.com/maxence-charriere/go-app)是一个使用 Go + WebAssembly 技术编写**渐进式 Web 应用**的库。WebAssembly 是一种可以运行在现代浏览器中的新式代码。近两年来,WebAssem ......
go-app app go

Go每日一库之29:gopsutil

## 简介 `gopsutil`是 Python 工具库[`psutil`](https://github.com/giampaolo/psutil) 的 Golang 移植版,可以帮助我们方便地获取各种系统和硬件信息。`gopsutil`为我们屏蔽了各个系统之间的差异,具有非常强悍的可移植性。有了 ......
gopsutil

Go每日一库之32:gron

## 简介 [`gron`](https://github.com/roylee0704/gron)是一个比较小巧、灵活的定时任务库,可以执行定时的、周期性的任务。`gron`提供简洁的、并发安全的接口。我们先介绍`gron`库的使用,然后简单分析一下源码。 ## 快速使用 先安装: ```bash ......
gron

Go每日一库之34:zap

## 简介 在很早之前的文章中,我们介绍过 Go 标准日志库[`log`](https://go-quiz.github.io/2020/02/07/godailylib/log/)和结构化的日志库[`logrus`](https://go-quiz.github.io/2020/02/07/god ......
zap

Go每日一库之35:zerolog

## 简介 每个编程语言都有很多日志库,因为记录日志在每个项目中都是必须的。前面我们介绍了标准日志库[`log`](https://go-quiz.github.io/2020/02/07/godailylib/log/)、好用的[`logrus`](https://go-quiz.github.i ......
zerolog

Go每日一库之36:nutsdb

## 简介 [`nutsdb`](https://github.com/xujiajun/nutsdb)是一个完全由 Go 编写的简单、快速、可嵌入的持久化存储。`nutsdb`与我们之前介绍过的[`buntdb`](https://go-quiz.github.io/2020/03/21/goda ......
nutsdb

Go每日一库之37:sqlc

## 简介 在 Go 语言中编写数据库操作代码真的非常痛苦!`database/sql`标准库提供的都是比较底层的接口。我们需要编写大量重复的代码。大量的模板代码不仅写起来烦,而且还容易出错。有时候字段类型修改了一下,可能就需要改动很多地方;添加了一个新字段,之前使用`select *`查询语句的地 ......
sqlc

Go每日一库之47:cli

## 简介 [`cli`](https://github.com/urfave/cli)是一个用于构建命令行程序的库。我们之前也介绍过一个用于构建命令行程序的库[`cobra`](https://go-quiz.github.io/2020/01/17/godailylib/cobra/)。在功能上 ......
cli

Go每日一库之48:cron

## 简介 [`cron`](https://github.com/robfig/cron)一个用于管理定时任务的库,用 Go 实现 Linux 中`crontab`这个命令的效果。之前我们也介绍过一个类似的 Go 库——[`gron`](https://go-quiz.github.io/2020 ......
cron

Go每日一库之63:ants

## 简介 处理大量并发是 Go 语言的一大优势。语言内置了方便的并发语法,可以非常方便的创建很多个轻量级的 goroutine 并发处理任务。相比于创建多个线程,goroutine 更轻量、资源占用更少、切换速度更快、无线程上下文切换开销更少。但是受限于资源总量,系统中能够创建的 goroutin ......
ants