general

command module
v1.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2022 License: MulanPSL-2.0 Imports: 1 Imported by: 0

README

general

介绍

我个人的一些go项目通用内容.从1.5开始.由于git不熟,1.5前的提交记录乱码七糟.被我删掉了.重新开始.

mutex

一个简单的互斥锁.通过Using的回调函数使用.可以避免忘记开锁.其使用过程难免出现闭包.经过测试性能影响不大.大概一次闭包环境的new和赋值. 用法非常简单,类型中继承后,通过Using方法使用类中其他资源. 例如list中的典型应用

type List[TYPE comparable] struct {
	buffer    []TYPE
	rollIndex int
	mutexs.Mutex
}

func (list *List[TYPE]) Count() (count int) {
	list.Using(func() {
		count = len(list.buffer)
	})
	return
}

enum

一种取值范围固定的类型.用于处理有限集合信息.通常可以把有限集合当成字符串来看待.而不是c语言的枚举.当然,为了压缩传输和兼容其他协议,有限集合中每一项都可以绑定值. 例如定义开关状态

maps

map的一些api扩展

slices

slice的一些扩展

run

协程和错误处理的一种满含自己风格的使用方法.可以多panic不用担心崩溃了.

cache

数据库的缓存.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL