Code Monkey home page Code Monkey logo

golib's Introduction

golib

golang常用库

  • config 配置文件读取库
  • errors 错误码设置
  • log 日志
  • db 数据库
  • cache 缓存
  • crypt 加密库
  • utils 常用工具

config

配置文件为toml格式的文件

import "github.com/Mueat/golib/config"

type Config struct {
	AppName string
	Basic   BasicConfig
	Log     map[string]LogConfig
	Mysql   map[string]MysqlConfig
	Redis   map[string]RedisConfig
}

func main() {
	conf := Config{}
	err := config.ParseConfig("./config.toml", &conf)
	if err != nil {
		panic(err)
	}
}

errors

错误定义文件格式如下

package errors

const (
	// success
	OK = 0
	// 系统错误
	System = 1
	// 参数错误
	Params = 2
)

使用解析方法生成错误字典文件

errors.ParseErrors("./errors/errors.go", "./errors/errors_map.go", "errors")

golib's People

Contributors

mueat avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.