- update utils

master
李光春 2 years ago
parent 71b7bb5cb6
commit 7cd582bc31

@ -2,7 +2,7 @@ package gobase64
import ( import (
"encoding/base64" "encoding/base64"
"go.dtapp.net/library/gophp" "go.dtapp.net/library/utils/gophp"
) )
// Encode base64编码 // Encode base64编码

@ -2,7 +2,7 @@ package godecimal
import ( import (
"fmt" "fmt"
"go.dtapp.net/library/gostring" "go.dtapp.net/library/utils/gostring"
"math" "math"
"strconv" "strconv"
) )

@ -1,7 +1,7 @@
package goenv package goenv
import ( import (
"go.dtapp.net/library/gostring" "go.dtapp.net/library/utils/gostring"
"os" "os"
"strings" "strings"
) )

@ -1,9 +1,9 @@
package goip package goip
import ( import (
"go.dtapp.net/library/goip/ip2region" "go.dtapp.net/library/utils/goip/ip2region"
"go.dtapp.net/library/goip/v4" "go.dtapp.net/library/utils/goip/v4"
"go.dtapp.net/library/goip/v6" "go.dtapp.net/library/utils/goip/v6"
"log" "log"
"strings" "strings"
) )

@ -2,7 +2,7 @@ package goip
import ( import (
"encoding/json" "encoding/json"
"go.dtapp.net/library/gorequest" "go.dtapp.net/library/utils/gorequest"
"net" "net"
) )

@ -3,7 +3,7 @@ package ip2region
import ( import (
_ "embed" _ "embed"
"errors" "errors"
"go.dtapp.net/library/gostring" "go.dtapp.net/library/utils/gostring"
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"

@ -4,7 +4,7 @@ import (
_ "embed" _ "embed"
"encoding/binary" "encoding/binary"
"errors" "errors"
"go.dtapp.net/library/gostring" "go.dtapp.net/library/utils/gostring"
"golang.org/x/text/encoding/simplifiedchinese" "golang.org/x/text/encoding/simplifiedchinese"
"io/ioutil" "io/ioutil"
"log" "log"

@ -4,7 +4,7 @@ import (
_ "embed" _ "embed"
"encoding/binary" "encoding/binary"
"errors" "errors"
"go.dtapp.net/library/gostring" "go.dtapp.net/library/utils/gostring"
"io/ioutil" "io/ioutil"
"log" "log"
"math/big" "math/big"

@ -2,7 +2,7 @@ package gojobs
import ( import (
"fmt" "fmt"
"go.dtapp.net/library/goip" "go.dtapp.net/library/utils/goip"
) )
var ip string var ip string

@ -2,7 +2,7 @@ package gojobs
import ( import (
"context" "context"
pb2 "go.dtapp.net/library/gojobs/pb" "go.dtapp.net/library/utils/gojobs/pb"
"google.golang.org/grpc" "google.golang.org/grpc"
"log" "log"
) )
@ -15,7 +15,7 @@ type CronConfig struct {
// Cron 定时任务 // Cron 定时任务
type Cron struct { type Cron struct {
CronConfig // 配置 CronConfig // 配置
Pub pb2.PubSubClient // 订阅 Pub pb.PubSubClient // 订阅
Conn *grpc.ClientConn // 链接信息 Conn *grpc.ClientConn // 链接信息
} }
@ -39,13 +39,13 @@ func NewCron(config *CronConfig) *Cron {
} }
// 新建一个客户端 // 新建一个客户端
c.Pub = pb2.NewPubSubClient(c.Conn) c.Pub = pb.NewPubSubClient(c.Conn)
return c return c
} }
// Send 发送 // Send 发送
func (c *Cron) Send(in *pb2.PublishRequest) (*pb2.PublishResponse, error) { func (c *Cron) Send(in *pb.PublishRequest) (*pb.PublishResponse, error) {
log.Printf("[定时任务]{广播开始}编号:%s 类型:%s ip%s\n", in.GetId(), in.GetValue(), in.GetIp()) log.Printf("[定时任务]{广播开始}编号:%s 类型:%s ip%s\n", in.GetId(), in.GetValue(), in.GetIp())
stream, err := c.Pub.Publish(context.Background(), in) stream, err := c.Pub.Publish(context.Background(), in)
if err != nil { if err != nil {

@ -4,7 +4,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"go.dtapp.net/library/goip" "go.dtapp.net/library/utils/goip"
"go.etcd.io/etcd/client/v3" "go.etcd.io/etcd/client/v3"
"log" "log"
"time" "time"

@ -2,7 +2,7 @@ package pb
import ( import (
"context" "context"
"go.dtapp.net/library/gojobs/pubsub" "go.dtapp.net/library/utils/gojobs/pubsub"
"log" "log"
"strings" "strings"
"time" "time"

@ -2,8 +2,8 @@ package gojobs
import ( import (
"errors" "errors"
pb2 "go.dtapp.net/library/gojobs/pb" "go.dtapp.net/library/utils/gojobs/pb"
"go.dtapp.net/library/gojobs/pubsub" "go.dtapp.net/library/utils/gojobs/pubsub"
"google.golang.org/grpc" "google.golang.org/grpc"
"log" "log"
"net" "net"
@ -44,7 +44,7 @@ func NewServer(config *ServerConfig) *Server {
s.Conn = grpc.NewServer() s.Conn = grpc.NewServer()
// 注册 // 注册
pb2.RegisterPubSubServer(s.Conn, pb2.NewPubSubServerService()) pb.RegisterPubSubServer(s.Conn, pb.NewPubSubServerService())
return s return s
} }

@ -2,8 +2,8 @@ package gojobs
import ( import (
"context" "context"
pb2 "go.dtapp.net/library/gojobs/pb" "go.dtapp.net/library/utils/gojobs/pb"
"go.dtapp.net/library/gouuid" "go.dtapp.net/library/utils/gouuid"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@ -16,7 +16,7 @@ type WorkerConfig struct {
// Worker 工作 // Worker 工作
type Worker struct { type Worker struct {
WorkerConfig // 配置 WorkerConfig // 配置
Pub pb2.PubSubClient // 订阅 Pub pb.PubSubClient // 订阅
Conn *grpc.ClientConn // 链接信息 Conn *grpc.ClientConn // 链接信息
} }
@ -44,14 +44,14 @@ func NewWorker(config *WorkerConfig) *Worker {
} }
// 新建一个客户端 // 新建一个客户端
w.Pub = pb2.NewPubSubClient(w.Conn) w.Pub = pb.NewPubSubClient(w.Conn)
return w return w
} }
// SubscribeCron 订阅服务 // SubscribeCron 订阅服务
func (w *Worker) SubscribeCron() pb2.PubSub_SubscribeClient { func (w *Worker) SubscribeCron() pb.PubSub_SubscribeClient {
stream, err := w.Pub.Subscribe(context.Background(), &pb2.SubscribeRequest{ stream, err := w.Pub.Subscribe(context.Background(), &pb.SubscribeRequest{
Id: gouuid.GetUuId(), Id: gouuid.GetUuId(),
Value: prefix, Value: prefix,
Ip: w.ClientIp, Ip: w.ClientIp,
@ -63,8 +63,8 @@ func (w *Worker) SubscribeCron() pb2.PubSub_SubscribeClient {
} }
// StartCron 启动任务 // StartCron 启动任务
func (w *Worker) StartCron() pb2.PubSub_SubscribeClient { func (w *Worker) StartCron() pb.PubSub_SubscribeClient {
stream, err := w.Pub.Subscribe(context.Background(), &pb2.SubscribeRequest{ stream, err := w.Pub.Subscribe(context.Background(), &pb.SubscribeRequest{
Id: gouuid.GetUuId(), Id: gouuid.GetUuId(),
Value: prefixSprintf(w.ClientIp), Value: prefixSprintf(w.ClientIp),
Ip: w.ClientIp, Ip: w.ClientIp,

@ -1,7 +1,7 @@
package golock package golock
import ( import (
"go.dtapp.net/library/goredis" "go.dtapp.net/library/utils/goredis"
"time" "time"
) )

@ -1,7 +1,7 @@
package golog package golog
import ( import (
"go.dtapp.net/library/goip" "go.dtapp.net/library/utils/goip"
"gorm.io/datatypes" "gorm.io/datatypes"
"gorm.io/gorm" "gorm.io/gorm"
"log" "log"

@ -1,7 +1,7 @@
package golog package golog
import ( import (
"go.dtapp.net/library/goip" "go.dtapp.net/library/utils/goip"
"gorm.io/datatypes" "gorm.io/datatypes"
"gorm.io/gorm" "gorm.io/gorm"
"log" "log"

@ -4,7 +4,7 @@ import (
"database/sql/driver" "database/sql/driver"
"errors" "errors"
"fmt" "fmt"
"go.dtapp.net/library/gotime" "go.dtapp.net/library/utils/gotime"
"gorm.io/gorm" "gorm.io/gorm"
"gorm.io/gorm/schema" "gorm.io/gorm/schema"
"time" "time"

@ -1,7 +1,7 @@
package gomongo package gomongo
import ( import (
"go.dtapp.net/library/gotime" "go.dtapp.net/library/utils/gotime"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsontype" "go.mongodb.org/mongo-driver/bson/bsontype"
"time" "time"

@ -2,8 +2,8 @@ package goorder
import ( import (
"fmt" "fmt"
"go.dtapp.net/library/gorandom" "go.dtapp.net/library/utils/gorandom"
"go.dtapp.net/library/gotime" "go.dtapp.net/library/utils/gotime"
) )
// GenerateOrDate 生成订单号 // GenerateOrDate 生成订单号

@ -1,7 +1,7 @@
package gophp package gophp
import ( import (
serialize2 "go.dtapp.net/library/gophp/serialize" "go.dtapp.net/library/utils/gophp/serialize"
"strconv" "strconv"
"strings" "strings"
"unicode" "unicode"
@ -9,12 +9,12 @@ import (
// Serialize 序列 // Serialize 序列
func Serialize(value any) ([]byte, error) { func Serialize(value any) ([]byte, error) {
return serialize2.Marshal(value) return serialize.Marshal(value)
} }
// Unserialize 反序列 // Unserialize 反序列
func Unserialize(data []byte) (any, error) { func Unserialize(data []byte) (any, error) {
return serialize2.UnMarshal(data) return serialize.UnMarshal(data)
} }
func BaseConvert(number string, frombase, tobase int) (string, error) { func BaseConvert(number string, frombase, tobase int) (string, error) {

@ -3,7 +3,7 @@ package serialize
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"go.dtapp.net/library/gostring" "go.dtapp.net/library/utils/gostring"
"reflect" "reflect"
"sort" "sort"
) )

@ -3,7 +3,7 @@ package serialize
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"go.dtapp.net/library/gostring" "go.dtapp.net/library/utils/gostring"
"strconv" "strconv"
) )

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save