提交 dac55eb4 编写于 作者: Y Your Name

完善注释

上级 8c59d071
......@@ -13,7 +13,7 @@ import (
"github.com/eolinker/goku-api-gateway/common/database"
"github.com/eolinker/goku-api-gateway/common/general"
"github.com/eolinker/goku-api-gateway/common/redis-manager"
redis_manager "github.com/eolinker/goku-api-gateway/common/redis-manager"
goku_node "github.com/eolinker/goku-api-gateway/goku-node"
"github.com/eolinker/goku-api-gateway/server/entity"
)
......@@ -69,11 +69,11 @@ func main() {
return
}
goku_node.InitLog()
log.Debug("goku_node.InitLog")
log.Debug("gokNode.InitLog")
r := redis_manager.Create(&config.Redis)
redis_manager.SetDefault(r)
log.Debug("redis_manager.SetDefault")
log.Debug("redis-manager.SetDefault")
// 其他需要初始化的模块
_ = general.General()
......
package queue
type GokuQueue interface {
Size() int //大小
Front() interface{} //第一个元素
End() interface{} //最后一个元素
IsEmpty() bool //是否为空
Enqueue(data interface{}) //入队
Dequeue() interface{} //出对
Clear() //清空
}
type Queue struct {
datastore []interface{}
theSize int
}
func (goku_queue *Queue) Clear() {
goku_queue.datastore = make([]interface{}, 0) //开辟内存
goku_queue.theSize = 0
}
func NewQueue() *Queue {
goku_queue := new(Queue)
goku_queue.Clear()
return goku_queue
}
func (goku_queue *Queue) Size() int {
return goku_queue.theSize //大小
}
func (goku_queue *Queue) Front() interface{} {
if goku_queue.Size() == 0 { //判断是否为空
return nil
}
return goku_queue.datastore[0]
}
func (goku_queue *Queue) End() interface{} {
if goku_queue.Size() == 0 { //判断是否为空
return nil
}
return goku_queue.datastore[goku_queue.theSize-1]
}
func (goku_queue *Queue) IsEmpty() bool {
return goku_queue.theSize == 0
}
func (goku_queue *Queue) Enqueue(data interface{}) {
goku_queue.datastore = append(goku_queue.datastore, data) //入队
goku_queue.theSize = goku_queue.theSize + 1
}
func (goku_queue *Queue) Dequeue() interface{} {
size := len(goku_queue.datastore)
if size < 1 { //判断是否为空
return nil
}
datastore := make([]interface{}, 0)
data := goku_queue.datastore[0]
if goku_queue.theSize > 1 {
datastore = goku_queue.datastore[1:] //截取
}
goku_queue.datastore = datastore
goku_queue.theSize = goku_queue.theSize - 1
return data
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册