diff --git a/server/internal/library/hggen/views/gohtml/tag_element.go b/server/internal/library/hggen/views/gohtml/tag_element.go index ec60d58..9e9ce1f 100644 --- a/server/internal/library/hggen/views/gohtml/tag_element.go +++ b/server/internal/library/hggen/views/gohtml/tag_element.go @@ -103,7 +103,7 @@ func (e *tagElement) write(bf *formattedBuffer, isPreviousNodeInline bool) bool } } - if e.isInline() || bytes.IndexAny(condensedBuffer.buffer.Bytes()[1:], "\n") == -1 { + if e.isInline() || bytes.ContainsAny(condensedBuffer.buffer.Bytes()[1:], "\n") { // If we're an inline tag, or there were no newlines were in the buffer, // replace the original with the condensed version condensedBuffer.buffer = bytes.NewBuffer(bytes.Join([][]byte{ diff --git a/server/internal/library/hggen/views/gohtml/utils.go b/server/internal/library/hggen/views/gohtml/utils.go index 6cf8200..25874c3 100644 --- a/server/internal/library/hggen/views/gohtml/utils.go +++ b/server/internal/library/hggen/views/gohtml/utils.go @@ -97,5 +97,5 @@ func (bf *formattedBuffer) writeToken(token string, kind formatterTokenType) { // unifyLineFeed unifies line feeds. func unifyLineFeed(s string) string { - return strings.Replace(strings.Replace(s, "\r\n", "\n", -1), "\r", "\n", -1) + return strings.ReplaceAll(strings.ReplaceAll(s, "\r\n", "\n"), "\r", "\n") } diff --git a/server/internal/library/hggen/views/utils.go b/server/internal/library/hggen/views/utils.go index f4872ff..588ea2a 100644 --- a/server/internal/library/hggen/views/utils.go +++ b/server/internal/library/hggen/views/utils.go @@ -8,14 +8,6 @@ package views import ( "context" "fmt" - "github.com/gogf/gf/v2/database/gdb" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/text/gregex" - "github.com/gogf/gf/v2/text/gstr" - "github.com/gogf/gf/v2/util/gconv" - "golang.org/x/tools/imports" "hotgo/internal/consts" "hotgo/internal/library/hggen/views/gohtml" "hotgo/internal/model" @@ -27,6 +19,15 @@ import ( "regexp" "strings" "unicode" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gconv" + "golang.org/x/tools/imports" ) // parseServFunName 解析业务服务名称 @@ -242,9 +243,10 @@ func CheckTreeTableFields(columns []*sysin.GenCodesColumnListModel) (err error) // CheckIllegalName 检查命名是否合理 func CheckIllegalName(errPrefix string, names ...string) (err error) { + reg, _ := regexp.Compile("^[a-z_][a-z0-9_]*$") for _, name := range names { name = strings.ToLower(name) - match, _ := regexp.MatchString("^[a-z_][a-z0-9_]*$", name) + match := reg.MatchString(name) if !match { err = gerror.Newf("%v存在格式不正确,必须全部小写且由字母、数字和下划线组成:%v", errPrefix, name) return diff --git a/server/internal/library/hgorm/dao_tenant.go b/server/internal/library/hgorm/dao_tenant.go index 940273c..c763012 100644 --- a/server/internal/library/hgorm/dao_tenant.go +++ b/server/internal/library/hgorm/dao_tenant.go @@ -7,10 +7,11 @@ package hgorm import ( "context" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/frame/g" "hotgo/internal/consts" "hotgo/utility/tree" + + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" ) // TenantRelation 租户关系 @@ -85,7 +86,7 @@ func GetTenantRelation(ctx context.Context, memberId int64) (tr *TenantRelation, } tr.UserId = memberId default: - err = gerror.Newf("未找到用户[%]的租户关系,部门类型[%v] 无效", memberId, tr.DeptType) + err = gerror.Newf("未找到用户[%v]的租户关系,部门类型[%v] 无效", memberId, tr.DeptType) return nil, err } return diff --git a/server/internal/library/location/location.go b/server/internal/library/location/location.go index 79839fa..f5bb91e 100644 --- a/server/internal/library/location/location.go +++ b/server/internal/library/location/location.go @@ -8,6 +8,13 @@ package location import ( "context" "fmt" + "hotgo/utility/validate" + "io" + "net" + "net/http" + "strings" + "time" + "github.com/gogf/gf/v2/encoding/gcharset" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" @@ -15,12 +22,6 @@ import ( "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" "github.com/kayon/iploc" - "hotgo/utility/validate" - "io" - "net" - "net/http" - "strings" - "time" ) const ( @@ -72,7 +73,7 @@ func WhoisLocation(ctx context.Context, ip string, retry ...int64) (*IpLocationD // 利用重试机制缓解高并发情况下限流的影响 // 毕竟这是一个免费的接口,如果你对IP归属地定位要求毕竟高,可以考虑换个付费接口 - if response.StatusCode != 200 { + if response.StatusCode != http.StatusOK { retryCount := defaultRetry if len(retry) > 0 { retryCount = retry[0] diff --git a/server/internal/library/queue/rocketmq.go b/server/internal/library/queue/rocketmq.go index ab77cce..6a23ef2 100644 --- a/server/internal/library/queue/rocketmq.go +++ b/server/internal/library/queue/rocketmq.go @@ -7,6 +7,12 @@ package queue import ( "context" + "hotgo/internal/consts" + "hotgo/utility/simple" + "hotgo/utility/validate" + "sync" + "time" + "github.com/apache/rocketmq-client-go/v2" "github.com/apache/rocketmq-client-go/v2/admin" "github.com/apache/rocketmq-client-go/v2/consumer" @@ -16,11 +22,6 @@ import ( "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/grpool" - "hotgo/internal/consts" - "hotgo/utility/simple" - "hotgo/utility/validate" - "sync" - "time" ) type RocketMq struct { @@ -191,7 +192,7 @@ func (r *RocketMq) ListenReceiveMsgDo(topic string, receiveDo func(mqMsg MqMsg)) err = r.consumerIns.Subscribe(topic, consumer.MessageSelector{}, func(ctx context.Context, msgs ...*primitive.MessageExt) (consumer.ConsumeResult, error) { for _, item := range msgs { - rocketManager.goPool.Add(ctx, func(ctx context.Context) { + _ = rocketManager.goPool.Add(ctx, func(ctx context.Context) { receiveDo(MqMsg{ RunType: ReceiveMsg, Topic: item.Topic,