解析yml 文件到对象
1 、
import (
"gopkg.in/yaml.v2"
)
type ServiceConfig struct {
Mq MqConfig `yaml:"mq"`
}
type MqConfig struct {
UserName string `yaml:"username"`
Password string `yaml:"password"`
Addr string `yaml:"addr"`
}
var (
Srv ServiceConfig
)
func LoadConfig(path string) error {
data, err := ioutil.ReadFile(filepath.Clean(path))
if err != nil {
return err
}
if err = yaml.Unmarshal(data, &Srv); err != nil {
return err
}
//todo 可以对属性做一些校验
// xxxx
}
日志之间的性能对比 GitHub - uber-go/zap: Blazing fast, structured, leveled logging in Go.
GitHub - sirupsen/logrus: Structured, pluggable logging for Go. | 23.7K | Logrus 是 Go (golang) 的结构化记录器,与标准库记录器 API 完全兼容。 | GORM 指南 | GORM - The fantastic ORM library for Golang, aims to be developer friendly. | |
GitHub - uber-go/zap: Blazing fast, structured, leveled logging in Go. | 20.3K | 快速的、结构化的、分层次的日志记录器 | 一文告诉你如何用好uber开源的zap日志库 | |
数据库:Golang ORM框架介绍及比较-阿里云开发者社区
https://github.com/go-gorm/gorm | https://github.com/acmestack/gorm-plus | |||
https://github.com/jmoiron/sqlx | ||||
redis:
GitHub - gomodule/redigo: Go client for Redis | 9.7k | |||
GitHub - redis/go-redis: Redis Go client | 18.6k | |||
rabbitmq:
kafka:
https://github.com/IBM/sarama | 11K | |||
https://github.com/segmentio/kafka-go | 7.2K | |||
http:
web框架:Go框架比较:goframe、beego、iris和gin-腾讯云开发者社区-腾讯云
Golang Web开发框架大比拼:找到适合你的框架_go web框架对比-优快云博客