nezha -> naza

pull/2/head
q191201771 5 years ago
parent 94cbffe32a
commit 721f5df776

@ -2,24 +2,24 @@
<br>
Go语言基础库
<br><br>
<a title="TravisCI" target="_blank" href="https://www.travis-ci.org/q191201771/nezha"><img src="https://www.travis-ci.org/q191201771/nezha.svg?branch=master"></a>
<a title="codecov" target="_blank" href="https://codecov.io/gh/q191201771/nezha"><img src="https://codecov.io/gh/q191201771/nezha/branch/master/graph/badge.svg?style=flat-square"></a>
<a title="goreportcard" target="_blank" href="https://goreportcard.com/report/github.com/q191201771/nezha"><img src="https://goreportcard.com/badge/github.com/q191201771/nezha?style=flat-square"></a>
<a title="TravisCI" target="_blank" href="https://www.travis-ci.org/q191201771/naza"><img src="https://www.travis-ci.org/q191201771/naza.svg?branch=master"></a>
<a title="codecov" target="_blank" href="https://codecov.io/gh/q191201771/naza"><img src="https://codecov.io/gh/q191201771/naza/branch/master/graph/badge.svg?style=flat-square"></a>
<a title="goreportcard" target="_blank" href="https://goreportcard.com/report/github.com/q191201771/naza"><img src="https://goreportcard.com/badge/github.com/q191201771/naza?style=flat-square"></a>
<br>
<a title="codesize" target="_blank" href="https://github.com/q191201771/nezha"><img src="https://img.shields.io/github/languages/code-size/q191201771/nezha.svg?style=flat-square?style=flat-square"></a>
<a title="license" target="_blank" href="https://github.com/q191201771/nezha/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square"></a>
<a title="lastcommit" target="_blank" href="https://github.com/q191201771/nezha/commits/master"><img src="https://img.shields.io/github/commit-activity/m/q191201771/nezha.svg?style=flat-square"></a>
<a title="commitactivity" target="_blank" href="https://github.com/q191201771/nezha/graphs/commit-activity"><img src="https://img.shields.io/github/last-commit/q191201771/nezha.svg?style=flat-square"></a>
<a title="codesize" target="_blank" href="https://github.com/q191201771/naza"><img src="https://img.shields.io/github/languages/code-size/q191201771/naza.svg?style=flat-square?style=flat-square"></a>
<a title="license" target="_blank" href="https://github.com/q191201771/naza/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square"></a>
<a title="lastcommit" target="_blank" href="https://github.com/q191201771/naza/commits/master"><img src="https://img.shields.io/github/commit-activity/m/q191201771/naza.svg?style=flat-square"></a>
<a title="commitactivity" target="_blank" href="https://github.com/q191201771/naza/graphs/commit-activity"><img src="https://img.shields.io/github/last-commit/q191201771/naza.svg?style=flat-square"></a>
<br>
<a title="pr" target="_blank" href="https://github.com/q191201771/nezha/pulls"><img src="https://img.shields.io/github/issues-pr-closed/q191201771/nezha.svg?style=flat-square&color=FF9966"></a>
<a title="hits" target="_blank" href="https://github.com/q191201771/nezha"><img src="https://hits.b3log.org/q191201771/nezha.svg?style=flat-square"></a>
<a title="language" target="_blank" href="https://github.com/q191201771/nezha"><img src="https://img.shields.io/github/languages/count/q191201771/nezha.svg?style=flat-square"></a>
<a title="toplanguage" target="_blank" href="https://github.com/q191201771/nezha"><img src="https://img.shields.io/github/languages/top/q191201771/nezha.svg?style=flat-square"></a>
<a title="godoc" target="_blank" href="https://godoc.org/github.com/q191201771/nezha"><img src="http://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat-square"></a>
<a title="pr" target="_blank" href="https://github.com/q191201771/naza/pulls"><img src="https://img.shields.io/github/issues-pr-closed/q191201771/naza.svg?style=flat-square&color=FF9966"></a>
<a title="hits" target="_blank" href="https://github.com/q191201771/naza"><img src="https://hits.b3log.org/q191201771/naza.svg?style=flat-square"></a>
<a title="language" target="_blank" href="https://github.com/q191201771/naza"><img src="https://img.shields.io/github/languages/count/q191201771/naza.svg?style=flat-square"></a>
<a title="toplanguage" target="_blank" href="https://github.com/q191201771/naza"><img src="https://img.shields.io/github/languages/top/q191201771/naza.svg?style=flat-square"></a>
<a title="godoc" target="_blank" href="https://godoc.org/github.com/q191201771/naza"><img src="http://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat-square"></a>
<br><br>
<a title="watcher" target="_blank" href="https://github.com/q191201771/nezha/watchers"><img src="https://img.shields.io/github/watchers/q191201771/nezha.svg?label=Watchers&style=social"></a>&nbsp;&nbsp;
<a title="star" target="_blank" href="https://github.com/q191201771/nezha/stargazers"><img src="https://img.shields.io/github/stars/q191201771/nezha.svg?label=Stars&style=social"></a>&nbsp;&nbsp;
<a title="fork" target="_blank" href="https://github.com/q191201771/nezha/network/members"><img src="https://img.shields.io/github/forks/q191201771/nezha.svg?label=Forks&style=social"></a>&nbsp;&nbsp;
<a title="watcher" target="_blank" href="https://github.com/q191201771/naza/watchers"><img src="https://img.shields.io/github/watchers/q191201771/naza.svg?label=Watchers&style=social"></a>&nbsp;&nbsp;
<a title="star" target="_blank" href="https://github.com/q191201771/naza/stargazers"><img src="https://img.shields.io/github/stars/q191201771/naza.svg?label=Stars&style=social"></a>&nbsp;&nbsp;
<a title="fork" target="_blank" href="https://github.com/q191201771/naza/network/members"><img src="https://img.shields.io/github/forks/q191201771/naza.svg?label=Forks&style=social"></a>&nbsp;&nbsp;
</p>
---
@ -32,10 +32,10 @@ pkg/ ......源码包
|-- bele/ ......提供了大小端的转换操作
|-- bininfo/ ......将编译时的 git 版本号时间Go 编译器信息打入程序中
|-- connection/ ......对 net.Conn 接口的二次封装
|-- log/ ......日志库
|-- mockserver/ ......模拟一些服务端,用于快速测试其它代码
|-- mockwriter/ ......模拟 Writer 接口,用于快速测试其它代码
|-- nazajson/ ......json 操作
|-- nazalog/ ......日志库
|-- unique/ ......对象唯一 ID
demo/ ......示例相关的代码
bin/ ......可执行文件编译输出目录
@ -45,8 +45,9 @@ bin/ ......可执行文件编译输出目录
无任何第三方依赖
#### 项目名 nezha 由来
#### 项目名 naza 由来
本仓库主要用于存放我自己写的一些 Go 基础库代码。目前只服务于我的另一个项目: [lal](https:////github.com/q191201771/lal)
nezha 即 哪吒,希望本仓库以后能像三头六臂,有多种武器的哪吒一样,为我提供多种工具。
naza 即哪吒(正确拼音为 nezha我女儿发音读作 naza少一个字母挺好~),希望本仓库以后能像三头六臂,有多种武器的哪吒一样,为我提供多种工具。

@ -1,3 +1,3 @@
module github.com/q191201771/nezha
module github.com/q191201771/naza
go 1.12

@ -3,7 +3,7 @@ package bele
import (
"bytes"
"encoding/binary"
"github.com/q191201771/nezha/pkg/assert"
"github.com/q191201771/naza/pkg/assert"
"testing"
)

@ -16,10 +16,10 @@ import (
// BuildGoVersion=`go version`
//
// go build -ldflags " \
// -X 'github.com/q191201771/nezha/pkg/bininfo.GitCommitLog=${GitCommitLog}' \
// -X 'github.com/q191201771/nezha/pkg/bininfo.GitStatus=${GitStatus}' \
// -X 'github.com/q191201771/nezha/pkg/bininfo.BuildTime=${BuildTime}' \
// -X 'github.com/q191201771/nezha/pkg/bininfo.BuildGoVersion=${BuildGoVersion}' \
// -X 'github.com/q191201771/naza/pkg/bininfo.GitCommitLog=${GitCommitLog}' \
// -X 'github.com/q191201771/naza/pkg/bininfo.GitStatus=${GitStatus}' \
// -X 'github.com/q191201771/naza/pkg/bininfo.BuildTime=${BuildTime}' \
// -X 'github.com/q191201771/naza/pkg/bininfo.BuildGoVersion=${BuildGoVersion}' \
// "
var (

@ -8,14 +8,14 @@ package connection
import (
"bufio"
"errors"
"github.com/q191201771/nezha/pkg/nazalog"
"github.com/q191201771/naza/pkg/nazalog"
"io"
"net"
"sync"
"time"
)
var connectionErr = errors.New("nezha.connection: fxxk")
var connectionErr = errors.New("naza.connection: fxxk")
type Connection interface {
// 包含 interface net.Conn 的所有方法
@ -170,13 +170,13 @@ func (c *connection) ReadAtLeast(buf []byte, min int) (n int, err error) {
if c.option.ReadTimeoutMS > 0 {
err = c.SetReadDeadline(time.Now().Add(time.Duration(c.option.ReadTimeoutMS) * time.Millisecond))
if err != nil {
nazalog.Debugf("nezha connection. error=%v, conn=%p", err, c)
nazalog.Debugf("naza connection. error=%v, conn=%p", err, c)
return 0, err
}
}
n, err = io.ReadAtLeast(c.r, buf, min)
if err != nil {
nazalog.Debugf("nezha connection. error=%v, conn=%p", err, c)
nazalog.Debugf("naza connection. error=%v, conn=%p", err, c)
c.close(err)
}
return n, err
@ -192,13 +192,13 @@ func (c *connection) ReadLine() (line []byte, isPrefix bool, err error) {
if c.option.ReadTimeoutMS > 0 {
err = c.SetReadDeadline(time.Now().Add(time.Duration(c.option.ReadTimeoutMS) * time.Millisecond))
if err != nil {
nazalog.Debugf("nezha connection. error=%v, conn=%p", err, c)
nazalog.Debugf("naza connection. error=%v, conn=%p", err, c)
return nil, false, err
}
}
line, isPrefix, err = bufioReader.ReadLine()
if err != nil {
nazalog.Debugf("nezha connection. error=%v, conn=%p", err, c)
nazalog.Debugf("naza connection. error=%v, conn=%p", err, c)
c.close(err)
}
return line, isPrefix, err
@ -208,13 +208,13 @@ func (c *connection) Read(b []byte) (n int, err error) {
if c.option.ReadTimeoutMS > 0 {
err = c.SetReadDeadline(time.Now().Add(time.Duration(c.option.ReadTimeoutMS) * time.Millisecond))
if err != nil {
nazalog.Debugf("nezha connection. error=%v, conn=%p", err, c)
nazalog.Debugf("naza connection. error=%v, conn=%p", err, c)
return 0, err
}
}
n, err = c.r.Read(b)
if err != nil {
nazalog.Debugf("nezha connection. error=%v, conn=%p", err, c)
nazalog.Debugf("naza connection. error=%v, conn=%p", err, c)
c.close(err)
}
return n, err
@ -232,13 +232,13 @@ func (c *connection) write(b []byte) (n int, err error) {
if c.option.WriteTimeoutMS > 0 {
err = c.SetWriteDeadline(time.Now().Add(time.Duration(c.option.WriteTimeoutMS) * time.Millisecond))
if err != nil {
nazalog.Debugf("nezha connection. error=%v, conn=%p", err, c)
nazalog.Debugf("naza connection. error=%v, conn=%p", err, c)
return 0, err
}
}
n, err = c.w.Write(b)
if err != nil {
nazalog.Debugf("nezha connection. error=%v, conn=%p", err, c)
nazalog.Debugf("naza connection. error=%v, conn=%p", err, c)
c.close(err)
}
return n, err
@ -254,12 +254,12 @@ func (c *connection) runWriteLoop() {
switch msg.t {
case wMsgTWrite:
if _, err := c.write(msg.b); err != nil {
nazalog.Debugf("nezha connection. error=%v, conn=%p", err, c)
nazalog.Debugf("naza connection. error=%v, conn=%p", err, c)
return
}
case wMsgTFlush:
if err := c.flush(); err != nil {
nazalog.Debugf("nezha connection. error=%v, conn=%p", err, c)
nazalog.Debugf("naza connection. error=%v, conn=%p", err, c)
c.flushDoneChan <- struct{}{}
return
}
@ -285,12 +285,12 @@ func (c *connection) flush() error {
if c.option.WriteTimeoutMS > 0 {
err := c.SetWriteDeadline(time.Now().Add(time.Duration(c.option.WriteTimeoutMS) * time.Millisecond))
if err != nil {
nazalog.Debugf("nezha connection. error=%v, conn=%p", err, c)
nazalog.Debugf("naza connection. error=%v, conn=%p", err, c)
return err
}
}
if err := w.Flush(); err != nil {
nazalog.Debugf("nezha connection. error=%v, conn=%p", err, c)
nazalog.Debugf("naza connection. error=%v, conn=%p", err, c)
c.close(err)
return err
}
@ -299,13 +299,13 @@ func (c *connection) flush() error {
}
func (c *connection) Close() error {
nazalog.Debugf("nezha connection Close. conn=%p", c)
nazalog.Debugf("naza connection Close. conn=%p", c)
c.close(nil)
return nil
}
func (c *connection) close(err error) {
nazalog.Debugf("nezha connection close. err=%v, conn=%p", err, c)
nazalog.Debugf("naza connection close. err=%v, conn=%p", err, c)
c.closeOnce.Do(func() {
if c.option.WriteChanSize > 0 {
c.exitChan <- struct{}{}
@ -330,7 +330,7 @@ func (c *connection) RemoteAddr() net.Addr {
func (c *connection) SetDeadline(t time.Time) error {
err := c.Conn.SetDeadline(t)
if err != nil {
nazalog.Debugf("nezha connection. error=%v, conn=%p", err, c)
nazalog.Debugf("naza connection. error=%v, conn=%p", err, c)
c.close(err)
}
return err
@ -339,7 +339,7 @@ func (c *connection) SetDeadline(t time.Time) error {
func (c *connection) SetReadDeadline(t time.Time) error {
err := c.Conn.SetReadDeadline(t)
if err != nil {
nazalog.Debugf("nezha connection. error=%v, conn=%p", err, c)
nazalog.Debugf("naza connection. error=%v, conn=%p", err, c)
c.close(err)
}
return err
@ -348,7 +348,7 @@ func (c *connection) SetReadDeadline(t time.Time) error {
func (c *connection) SetWriteDeadline(t time.Time) error {
err := c.Conn.SetWriteDeadline(t)
if err != nil {
nazalog.Debugf("nezha connection. error=%v, conn=%p", err, c)
nazalog.Debugf("naza connection. error=%v, conn=%p", err, c)
c.close(err)
}
return err

@ -1,8 +1,8 @@
package connection
import (
"github.com/q191201771/nezha/pkg/assert"
"github.com/q191201771/nezha/pkg/nazalog"
"github.com/q191201771/naza/pkg/assert"
"github.com/q191201771/naza/pkg/nazalog"
"net"
"testing"
)

@ -1,7 +1,7 @@
package mockserver
import (
"github.com/q191201771/nezha/pkg/nazalog"
"github.com/q191201771/naza/pkg/nazalog"
"net"
"time"
)

@ -1,7 +1,7 @@
package mockserver
import (
"github.com/q191201771/nezha/pkg/assert"
"github.com/q191201771/naza/pkg/assert"
"net"
"testing"
"time"

@ -1,7 +1,7 @@
package mockwriter
import (
"github.com/q191201771/nezha/pkg/assert"
"github.com/q191201771/naza/pkg/assert"
"testing"
)

@ -1,8 +1,8 @@
package nazajson
import (
"github.com/q191201771/nezha/pkg/assert"
"github.com/q191201771/nezha/pkg/nazalog"
"github.com/q191201771/naza/pkg/assert"
"github.com/q191201771/naza/pkg/nazalog"
"testing"
)

@ -7,7 +7,7 @@ import (
"os"
"testing"
"github.com/q191201771/nezha/pkg/assert"
"github.com/q191201771/naza/pkg/assert"
)
func TestLogger(t *testing.T) {

@ -1,7 +1,7 @@
package unique
import (
"github.com/q191201771/nezha/pkg/assert"
"github.com/q191201771/naza/pkg/assert"
"sync"
"testing"
)

@ -28,7 +28,7 @@ fi
echo "CHEFERASEME run coverage test..."
echo "" > coverage.txt
for d in $(go list ./... | grep -v vendor | grep nezha/pkg); do
for d in $(go list ./... | grep -v vendor | grep naza/pkg); do
go test -race -coverprofile=profile.out -covermode=atomic $d
if [ -f profile.out ]; then
cat profile.out >> coverage.txt

Loading…
Cancel
Save