All Projects → dearcode → crab

dearcode / crab

Licence: GPL-3.0 license
Golang API Framework

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to crab

spdlog setup
spdlog setup initialization via file configuration for convenience.
Stars: ✭ 68 (+19.3%)
Mutual labels:  config, log
Co
Art of C++. Flag, logging, unit-test, json, go-style coroutine and more.
Stars: ✭ 2,264 (+3871.93%)
Mutual labels:  config, log
rust cms
使用Rust编写一个CMS(内容管理系统)可以做为个人博客,公司网站
Stars: ✭ 32 (-43.86%)
Mutual labels:  config, log
node-config
nodejs的配置中心
Stars: ✭ 53 (-7.02%)
Mutual labels:  config
ConfigAPI
GSON-like ORM for Bukkit YAML API's
Stars: ✭ 23 (-59.65%)
Mutual labels:  config
dotfiles
My personal monorepo: dotfiles, /etc-files, single-file scripts, vim plugins, webexts/userscripts, xmonad config, all that stuff…
Stars: ✭ 84 (+47.37%)
Mutual labels:  config
dotfiles
Linux configuration files (dotfiles) and some useful scripts
Stars: ✭ 22 (-61.4%)
Mutual labels:  config
profig
A straightforward configuration library for Python.
Stars: ✭ 26 (-54.39%)
Mutual labels:  config
dotfiles
My dotfiles, use it with care 😅
Stars: ✭ 20 (-64.91%)
Mutual labels:  config
v13-Discord-Bot
This is my V13 Discord Bot, it has around 95 commands, 17 events, and stores all kinds of data in an SQL database for ease of access. Not to mention a unique style and friendly help menu interface. Used by over 25 people in popular company based servers, this will bring you a professional look that tops your competition.
Stars: ✭ 38 (-33.33%)
Mutual labels:  config
prettier-config-solidity
Prettier config optimized to reduce AST churn & conform to solidity spec
Stars: ✭ 28 (-50.88%)
Mutual labels:  config
dotfiles
My dotfiles based on Makefile
Stars: ✭ 150 (+163.16%)
Mutual labels:  config
nvim-config
My neovim config
Stars: ✭ 63 (+10.53%)
Mutual labels:  config
dotfiles
My personal configuration and bootstrap files
Stars: ✭ 14 (-75.44%)
Mutual labels:  config
LogiAM
基于日志模板构建,采集任务动态管控、数据质量精确度量,一站式日志采集平台
Stars: ✭ 199 (+249.12%)
Mutual labels:  log
hb-config
hb-config: easy to configure your python project especially Deep Learning experiments
Stars: ✭ 21 (-63.16%)
Mutual labels:  config
plaster
Application config settings abstraction layer.
Stars: ✭ 19 (-66.67%)
Mutual labels:  config
LogESP
Open Source SIEM (Security Information and Event Management system).
Stars: ✭ 162 (+184.21%)
Mutual labels:  log
Log
Daily logging tool and data visualizer.
Stars: ✭ 30 (-47.37%)
Mutual labels:  log
sconfig
Scala configuration library supporting HOCON for Scala, Java, Scala.js, and Scala Native
Stars: ✭ 99 (+73.68%)
Mutual labels:  config

Crab 开发必备库

Logo

codecov

config

加载ini格式的配置文件, 支持以;或者#开头的注释

type testConf struct {
	DB struct {
		Domain string
		Port   int `default:"9088"`
		Enable bool
	}
    aaa int
}

var conf testConf
if err := LoadConfig(path, &conf); err != nil {
    t.Fatalf(errors.ErrorStack(err))
}
t.Logf("conf:%+v", conf)

配置文件

 [db]
domain    =jd.com
enable=true
# test comments
;port=3306

只要传入对应的ini文件全路径及struct指针就可以了,简单高效.
运行结果:

conf:{DB:{Domain:jd.com Port:9088 Enable:true} aaa:0}

注意:只会解析有访问权限的变量(大写)

handler

简单高效的HTTP路由,支持指定接口函数,支持自动注册接口
指定接口注册示例:

handler.Server.AddHandler(handler.GET, "/test/", false, onTestGet)
handler.Server.AddHandler(handler.POST, "/test/", false, onTestPost)
handler.Server.AddHandler(handler.DELETE, "/test/", false, onTestDelete)

自动注册接口示例:

//以包名为路径
handler.Server.AddInterface(&user{}, "")
//指定path
handler.Server.AddInterface(&user{}, "/api/user/")

type user struct {
}

//DoGet 默认get方法
func (u *user) DoGet(w http.ResponseWriter, r *http.Request) {
    w.Write([]byte("Get user"))
}

//DoPost 默认post方法
func (u *user) DoPost(w http.ResponseWriter, r *http.Request) {
    w.Write([]byte("Post user"))
}

orm

只支持mysql
查询示例

result := struct {
	ID       int64
	User     string
	Password string
}{}

if err = NewStmt(db, "userinfo").Where("id=2").Query(&result); err != nil {
	t.Fatal(err.Error())
}

修改示例

data := struct {
	User     string
	Password string
}{
	User:     fmt.Sprintf("new_user_%d", time.Now().Unix()),
	Password: fmt.Sprintf("new_password_%d", time.Now().Unix()),
}

id, err := NewStmt(db, "userinfo").Where("id=2").Update(&data)
if err != nil {
	t.Fatal(err.Error())
}

添加示例

data := struct {
	ID       int64 `db_defult:"auto"`
	User     string
	Password string
}{
	User:     fmt.Sprintf("user_%d", time.Now().Unix()),
	Password: fmt.Sprintf("password_%d", time.Now().Unix()),
}

id, err := NewStmt(db, "userinfo").Insert(&data)
if err != nil {
	t.Fatal(err.Error())
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].