CATEGORY
goang
gossh go写的开源工具 批量操作服务器gossh go写的开源工具 批量操作服务器 gossh提供3种核心功能: 连接到文章 · 2023/02/14go get -ugo get u go get u update 的意思文章 · 2023/02/15GOST- GO Simple TunnelGOST GO Simple Tunnel 多端口监听 可设置转发代理,支持多级转发(代理链) 支持标准H文章 · 2023/02/16golang 空结构体 struct{} 作用golang 空结构体 struct{} 作用 原文地址 segmentfault.com 大家好,我是煎鱼。在 Go 语言中,有一个比较特殊的类型,经常会有刚接触 Go 的小伙伴问到,又或是不理解。他就是 Go 里的空结构体文章 · 2023/02/21go 项目目录结构 规范go 项目目录结构 规范 原文地址 github.com Standard Go Project Layout =文章 · 2023/02/21golang Prometheusgolang Prometheus 参考代码: OpenIMServer 基础: http : if config.Config.Prometheus.Enable { promePkg.NewApiRequestCounter() promeP文章 · 2023/02/23golang contextgolang context 什么是context? context是一种通知手段,例如现在后台有一个监听进程,你要如何在主进程中停止这个监听进程呢?有人会说,select+channel好了嘛,只要主进程往channel里面写数据,后台监听进程读取到channel里面的数据就停止,这其实是一个不错的方法,但是如果后台文章 · 2023/02/23golang context emptyCtx valueCtx cancelCtx timerCtxgolang context emptyCtx valueCtx cancelCtx timerCtx context 包提供了四种实现了 Context 接口的 struct。分别为最基础的 emptyCtx,包含键值对的 valu文章 · 2023/02/23golang struct{} 一个作为key的用法golang struct{} 一个作为key的用法 type keyType struct{} //空struct{}作为key,不占用内存空间 var xxxKey struct{} //同时避免了不同包使用ctx传值时出现冲突 var xxxKey2 keyType // 如果也是struct{} 。那么会覆盖。文章 · 2023/02/23基于 context.Context 的 Golang loader 缓存基于 context.Context 的 Golang loader 缓存 本文由 简悦 SimpRead 转码, 原文地址 juejin.cn 请求放大的问题。 做了文章 · 2023/02/23golang 函数选项模式golang 函数选项模式 本文由 简悦 SimpRead 转码, 原文地址 mp.weixin.qq.com 前言 通过这篇文章《[为什么说 Go 的函数是”文章 · 2023/02/28gomobile 开发android IOS SDKgomobile 开发android IOS SDK The Go mobile repository holds packages and build tools for u文章 · 2023/03/01当 Go struct 遇上 Mutex当 Go struct 遇上 Mutex 原文地址 juejin.cn struct 是我们写 Go 必然会用到的关键字, 不过当 struct 遇上一些比较特殊类型的时候, 你注意过你的程序是否正常吗 ? 一段代码 type文章 · 2023/10/17go json.RawMessagego json.RawMessage // RawMessage is a raw encoded JSON value. // It implements Marshaler and Unmarshaler and can // be used to delay JSON decoding or precompute文章 · 2023/03/01golang cobra 命令库golang cobra 命令库 这篇文章提取摘要 [ ](文章 · 2023/03/02golang viper库golang viper库 viper 是一个配置解决方案,拥有丰富的特性: 支持 JSON/TOML/YAML/HCL/envfile/Java properties 等多种格式的配置文件; 可以设置监听配置文件的修改,修改时自动加载新的配置; 从环境变量、命令行选项和io.Reader中读取配置; 从远程配置系统中文章 · 2023/03/03一图直接懂gomod配置一图直接懂gomod配置 一图直接懂gomod配置 golang的go.mod的层级嵌套问题文章 · 2023/03/03go pflag vs flaggo pflag vs flag pflag 包与 flag 包的工作原理甚至是代码实现都是类似的,下面是 pflag 相对 flag 的一些优势: 支持更加精细的参数类型:例如,flag 只支持 uint 和 uint64,而 pflag 额外支持 uint8、uint16、int32 等类型。 支持更多参数类型:i文章 · 2023/03/03golang 交叉编译golang 交叉编译 GOOS: 目标平台的操作系统(darwin freebsd linux windows) GOARCH 目标平台的架构是32位或64位(386 amd64 arm) GOOS=linux GOARCH="amd64" go build o cmd 386 代表 32 位系统,也称为 i386。文章 · 2023/03/08go 参数校验 GoFrame/gvalid vs go-playground/validatorgo 参数校验 GoFrame/gvalid vs goplayground/validator 原文地址 zhuanlan.zhihu.com GoFrame——数据校验之结构体校验 GoFrame中gvalid模块实现了非常强大的数文章 · 2023/03/08Go Test 单元测试简明教程 | 快速入门Go Test 单元测试简明教程 | 快速入门 原文 测试用例文章 · 2023/03/04golang lo库 -stream处理golang lo库 stream处理 ✨ samber/lo is a Lodashstyle Go library based on Go 1.18+ Generics. 采用泛型。工具类库 stream处理 It may look like [Lodash](文章 · 2023/03/04go singleflight 缓存击穿 缓存一致性go singleflight 缓存击穿 缓存一致性 一致性 一致性问题 2个线程 协程,因为先后顺序不同,导致 最后update cache时候,不一文章 · 2023/03/05不要忽略 goroutine 的启动时间, for range 陷阱不要忽略 goroutine 的启动时间, for range 陷阱 原文地址 mp.weixin.qq.com 小菜刀的项目中需要将数据推给多个服务器,大致如下 1package main 2 3import (文章 · 2023/03/10golang gout http 工具golang gout http 工具 支持链式 package main import ( "fmt" "github.com/guonaihong/gout" "time" ) // 用于解析 服务端 返回的http body type RspBody struct { ErrMsg string json:"er文章 · 2023/03/10grpc stream 单向stream 双向streamgrpc stream 单向stream 双向stream 前言 gRPC Streaming 是基于 HTTP/2 的 本章节将介绍 gRPC 的流式,分为三种类型: Serverside streaming RPC:服务器端流式 RPC Clientside streaming RPC:客户端流式 RPC Bidi文章 · 2023/03/10grpc 同端口 ,同时启用httpgrpc 同端口 ,同时启用http 关键一点,gRPC 的协议是基于 HTTP/2 的,因此应用程序能够在单个 TCP 端口上提供 HTTP/1.1 和 gRPC 接口服务(两种不同的流量) 怎么同时提供 HTTP 接口 检测协议 if r.ProtoMajor == 2 && strings.Contains(r.文章 · 2023/03/11grpc 自定义认证grpc 自定义认证 原文地址 eddycjy.com 前言 在前面的章节中,我们介绍了两种(证书算一种)可全局认证的方法: 1. [TLS 证书认证](文章 · 2023/03/11grpc deadlinegrpc deadline 客户端 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Duration(5 time.Second))) defer cancel() ........ resp, err := c文章 · 2023/03/11gprc grpc_middleware.WithUnaryServerChain 链式调用gprc grpcmiddleware.WithUnaryServerChain 链式调用 opts := []grpc.ServerOption{ //grpc.Creds(c), grpcmiddleware.WithUnaryServerChain( RecoveryInterceptor, LoggingInt文章 · 2023/03/13go使用build tags实现条件编译go使用build tags实现条件编译 原文地址 在 C/C++ 中可以通过宏定义实现条件编译,比如在不同平台的机器上,调用不同的函数,或者通过编译是传递参数,调用不同的函数,比如下面的例子 C++ 条文章 · 2023/03/16从 io.Reader 中读数据从 io.Reader 中读数据 原文地址 colobu.com Go 的标准库提供了多个从 io.Reader 中读取数据的方法 (io、ioutil),本文通过从 net.Conn 中读取数据为例,演示各种方文章 · 2023/03/16百万 Go TCP 连接的思考: epoll方式减少资源占用百万 Go TCP 连接的思考: epoll方式减少资源占用 原文地址 colobu.com 前几天 Eran Yanay 在 Gophercon Israel 分享了一个讲座:Going Infinite, han文章 · 2023/03/15