Go Core - Entity
|Word Count:0|Reading Time:1mins
Author: zhongmingmao
Copyright Notice: All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.
Related Articles

2022-05-15
Go Core - Array + Slice

2022-05-15
Go Core - List + Ring

2022-04-30
Go Engineering - Foundation - Linting
golangci-lint 优点 速度快 基于 gometalinter 开发,平均速度比 gometalinter 快 5 倍 并行检查代码 + 复用 go build 缓存 + 缓存分析结果 可配置 支持 YAML 格式的配置文件 IDE 集成 VS Code + Goland Linter 聚合器 集成了很多 Linter,无需单独安装,并且支持自定义 Linter 最小误报数 调整了所集成的 Linter 的默认设置,大幅减少误报 良好的输出 检查出问题的源码文件、行号和错误行内容 不符合检查规则的原因 报错的 Linter 更迭速度快 不断有新的 Linter 被集成进来 使用者:Google、Facebook、Istio、Red Hat OpenShift 等 golangci-lint 命令 cache123456789$ golangci-lint cache statusDir: /Users/zhongmingmao/Library/Caches/golangci-lintSize: 1.9MiB$ golangci-lint cache clea...

2023-05-07
Go Engineering - Doc
Swagger Swagger 是一套围绕 OpenAPI 规范构建的开源工具 Component Desc Swagger Editor 基于浏览器的编辑器,可以编写 OpenAPI 规范,并实时预览 Swagger UI 将 OpenAPI 规范呈现为交互式 API 文档 Swagger Codegen 根据 OpenAPI 规范,生成服务器存根和客户端代码库,涵盖 40 多种语言 OpenAPI OpenAPI 是一个 API 规范,其前身为 Swagger 规范 通过定义一种用来描述 API 格式或者 API 定义的 DSL,来规范 RESTful API 的开发过程 OpenAPI 3.0 ≈ Swagger 2.0 API 基本信息 对 API 的描述,介绍 API 可以实现的功能 每个 API 上可用的 Path 和 Method 每个 API 的输入和返回参数 验证方法 联系信息、许可证、使用条款和其它信息 OpenAPI 是一个 API 规范,而 Swagger 是实现该 API 规范的工具 go-swagger特性 功能强大、高性能、可以根据代...

2022-05-01
Go Engineering - Foundation - Error - Code
设计方式 场景:用户账号没有找到 200 HTTP Code 通常代表的是 HTTP Transport 层的状态信息;但对性能有一定的影响,因为需要解析 HTTP Body 12345678{ "error": { "message": "Syntax error \"Field picture specified more than once. This is only possible before version 2.1\" at character 23: id,name,picture,picture", "type": "OAuthException", "code": 2500, "fbtrace_id": "xxxxxxxxxxx" }} 4xx + 简单信息 可以让客户端快速感知请求失败,但提供的信息过于简单,不能准确地定位问题 ...

2023-05-02
Go Engineering - Design Pattern
设计模式 创建型模式 提供了一种在创建对象的同时隐藏创建逻辑的方式 单例模式饿汉方式 在包被加载时创建 12345678910package singletontype Singleton struct {}var instance *Singleton = &Singleton{}func GetInstance() *Singleton { return instance} 懒汉方式 在第一次使用时创建 - 使用最多,但非并发安全,需要加锁 不加锁1234567891011121314package singletontype Singleton struct {}var instance *Singleton// GetInstance is not thread-safefunc GetInstance() *Singleton { if instance == nil { instance = &Singleton{} ...
Announcement
Things are always unexpected!





