mirror of
https://github.com/xxjwxc/public.git
synced 2025-09-26 11:51:14 +08:00
new
This commit is contained in:
@@ -1,95 +0,0 @@
|
||||
package goleveldb
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"../../data/config"
|
||||
"../log"
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
)
|
||||
|
||||
var m_db *leveldb.DB = nil
|
||||
|
||||
func init() {
|
||||
Clear();
|
||||
creat()
|
||||
}
|
||||
|
||||
func creat(){
|
||||
if m_db == nil{
|
||||
var err error
|
||||
m_db, err = leveldb.OpenFile(config.GetLevelDbDir(), nil)
|
||||
if err != nil {
|
||||
log.Print(log.Log_Error, err.Error())
|
||||
m_db.Close()
|
||||
m_db = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
清空数据
|
||||
*/
|
||||
func Clear() bool {
|
||||
Close();
|
||||
os.RemoveAll(config.GetLevelDbDir());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
关闭
|
||||
*/
|
||||
func Close(){
|
||||
if m_db != nil{
|
||||
m_db.Close()
|
||||
m_db = nil;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*获取
|
||||
*/
|
||||
func Get(key []byte) (data []byte, err error) {
|
||||
data = nil
|
||||
data, err = m_db.Get(key, nil)
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
设置
|
||||
*/
|
||||
func Set(key, value []byte) error {
|
||||
err := m_db.Put(key, value, nil)
|
||||
return err
|
||||
}
|
||||
|
||||
/*
|
||||
删除
|
||||
*/
|
||||
func Delete(key []byte) error {
|
||||
return m_db.Delete(key, nil)
|
||||
}
|
||||
|
||||
/*
|
||||
*获取
|
||||
*/
|
||||
func Getkv(key string) (data []byte, err error) {
|
||||
return Get([]byte(key))
|
||||
}
|
||||
|
||||
/*
|
||||
*获取
|
||||
*/
|
||||
func Setkv(key string, value []byte) error {
|
||||
return Set([]byte(key), value)
|
||||
}
|
||||
|
||||
/*
|
||||
删除
|
||||
*/
|
||||
func Deletekv(key string) error {
|
||||
return Delete([]byte(key))
|
||||
}
|
||||
|
||||
|
@@ -2,14 +2,13 @@ package mydraw
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"public/mydraw"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMytest(t *testing.T) {
|
||||
pen, b := mydraw.OnGetPen("./luximr.ttf", 0, 0, 0, 255)
|
||||
pen, b := OnGetPen("./luximr.ttf", 0, 0, 0, 255)
|
||||
if b {
|
||||
var hdc mydraw.HDC
|
||||
var hdc HDC
|
||||
hdc.SetBg("./src.png")
|
||||
pen.Dpi = 200
|
||||
pen.FontSize = 16
|
||||
|
@@ -9,6 +9,6 @@ import (
|
||||
|
||||
func Test_kdn(t *testing.T) {
|
||||
kdn := New("1111111", "11111111-1111-1111-1111-11111111111111")
|
||||
result := kdn.GetLogisticsTrack("4304678557725", "YD")
|
||||
result := kdn.GetLogisticsTrack("4304678557725", "YD", "")
|
||||
fmt.Printf(tools.JSONDecode(result))
|
||||
}
|
||||
|
@@ -21,5 +21,5 @@ func TestMain(t *testing.T) {
|
||||
|
||||
// time.Sleep(1 * time.Second)
|
||||
|
||||
c.Terminal() // 进入
|
||||
c.EnterTerminal() // 进入
|
||||
}
|
||||
|
@@ -6,12 +6,12 @@ package mywebsocket
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"public/mycache"
|
||||
"public/mylog"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ant0ine/go-json-rest/rest"
|
||||
"github.com/xxjwxc/public/mycache"
|
||||
"github.com/xxjwxc/public/mylog"
|
||||
|
||||
"golang.org/x/net/websocket"
|
||||
)
|
||||
|
@@ -13,4 +13,3 @@ type Sign_client_tbl struct {
|
||||
Expire_time time.Time //超时时间
|
||||
Strict_verify int //是否强制验证:0:用户自定义,1:强制
|
||||
}
|
||||
z
|
@@ -2,15 +2,16 @@ package sign
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"public/message"
|
||||
"public/tools"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/xxjwxc/public/message"
|
||||
"github.com/xxjwxc/public/tools"
|
||||
)
|
||||
|
||||
func Test_sing(t *testing.T) {
|
||||
now := time.Now()
|
||||
str := "1" + tools.GetTimeString(now)
|
||||
str := "1" + tools.GetTimeStr(now)
|
||||
str += "1.0001"
|
||||
fmt.Println(str)
|
||||
ttt := tools.Md5Encoder(str)
|
||||
|
@@ -137,3 +137,8 @@ func Sha1Encrypt(str string) string {
|
||||
func GetUtf8Str(str string) []rune {
|
||||
return []rune(str)
|
||||
}
|
||||
|
||||
// GetUtf8Len 获取中文字符的长度
|
||||
func GetUtf8Len(str string) int {
|
||||
return len([]rune(str))
|
||||
}
|
||||
|
Reference in New Issue
Block a user