链接 动态modbus go

Go每日一库之102:grpcurl

[grpcurl](https://github.com/fullstorydev/grpcurl)是一个命令行工具,使用它可以在命令行中访问gRPC服务,就像使用curl访问http服务一样。 ## 准备 **在gRPC服务中注册reflection服务:** gRPC服务是使用Protobuf( ......
grpcurl 102

Go每日一库之107:errors

> 目前实现最优雅,打印堆栈良好的错误包。 # 下载安装 `go get -x github.com/pkg/errors` # 主要函数 ```go // 新生成一个错误, 带堆栈信息 func New(message string) error //只附加新的信息 func WithMessag ......
errors 107

Go每日一库之106:hystrix(熔断)

## 背景 随着微服务的流行,服务之间的调用可能变得越来越复杂,一个业务流程可能需要调用五六个甚至更多服务,这就会导致,假设某个服务出现问题,严重可能出现服务器负载过高,导致服务雪崩的现象。 因此为了防止此现象的发生,就需要考虑服务熔断机制,根据自身业务的需求,将其应用到服务中。 `什么是熔断`:可 ......
hystrix 106

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

3.动态代理

动态代理 为什么需要代理: 代理可以无侵入式的给对象增强其他的功能; 代理长什么样: 代理里面就是对象要被代理的方法; Java通过什么来保证代理的样子: 通过接口保证,后面的对象和代理需要实现同一个接口; 接口中就是被代理的所有方法; 代码实现: javabean类: package com.ca ......
动态

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

面向对象 静态方法和动态方法 ;静态更先进因为新建和被调用时不需要传self

展示动态方法 需要加self # A.py 调用B的制作伞 和扇子 from B import Handmade class Weather: def __init__(self, type): self.type = type def action(self): f = Handmade.make ......
静态 方法 对象 先进 动态

编译链接概念,VMA/LMA是什么

编译基础概念 为了描述链接器脚本语言,我们需要定义一些基本概念和词汇。 链接器干的主要事情就是把输入文件整合成一个输出文件。那么输入是什么?输出是什么?怎么整合?整合的是什么信息? 输入和输出文件都是object文件格式。它们都称为目标文件。输出文件又称为可执行文件。它们的内容格式类似,都有很多的s ......
概念 链接 VMA LMA

C语言 静态库和动态库生成

文件目录结构 tree . ├── bin ├── include │ └── calc.h ├── lib │ ├── add.c │ ├── div.c │ ├── mul.c │ └── sub.c └── src └── main.c 4 directories, 6 files 静态库生成 ......
静态 语言 动态

动态规划杂题选练

\(\text{CF908G}\) 题目描述 给\(n<=10^{700}\),问1到n中每个数在各数位排序后得到的数的和。答案膜 \(1e9+7\) 。 思路点拨 不是很难,自己想一会可以想出来。 因为 \(n\) 比较大,所以我们考虑数位dp。因为每一种数组产生的贡献十分复杂,所以我们将每一数字 ......
动态

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