Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# If a copy of the MIT was not distributed with this file,
# You can obtain one at https://github.com/gogf/gf.

name: GolangCI Lint
name: golangci-lint
on:
push:
branches:
Expand Down
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "2"
run:
concurrency: 4
go: "1.23"
go: "1.25"
modules-download-mode: readonly
issues-exit-code: 2
tests: false
Expand Down Expand Up @@ -188,7 +188,7 @@ formatters:
- blank
- default
- dot
- prefix(github.com/gogf/gf)
- prefix(github.com/gogf/gf/v2)
- prefix(github.com/gogf/gf/cmd)
- prefix(github.com/gogf/gfcontrib)
- prefix(github.com/gogf/gf/example)
Expand Down
4 changes: 2 additions & 2 deletions cmd/gf/internal/cmd/cmd_z_unit_gen_dao_issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func Test_Gen_Dao_Issue3459(t *testing.T) {
filepath.FromSlash(testPath + "/model/do/table_user.go"),
filepath.FromSlash(testPath + "/model/entity/table_user.go"),
}
for i, _ := range files {
for i := range files {
//_ = gfile.PutContents(expectFiles[i], gfile.GetContents(files[i]))
t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i]))
}
Expand Down Expand Up @@ -450,7 +450,7 @@ func Test_Gen_Dao_Issue3749(t *testing.T) {
filepath.FromSlash(testPath + "/model/do/table_user.go"),
filepath.FromSlash(testPath + "/model/entity/table_user.go"),
}
for i, _ := range files {
for i := range files {
//_ = gfile.PutContents(expectFiles[i], gfile.GetContents(files[i]))
t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i]))
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func Test_Gen_Dao_Default(t *testing.T) {
filepath.FromSlash(testPath + "/model/do/table_user.go"),
filepath.FromSlash(testPath + "/model/entity/table_user.go"),
}
for i, _ := range files {
for i := range files {
t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i]))
}
})
Expand Down Expand Up @@ -208,7 +208,7 @@ func Test_Gen_Dao_TypeMapping(t *testing.T) {
filepath.FromSlash(testPath + "/model/do/table_user.go"),
filepath.FromSlash(testPath + "/model/entity/table_user.go"),
}
for i, _ := range files {
for i := range files {
//_ = gfile.PutContents(expectFiles[i], gfile.GetContents(files[i]))
t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i]))
}
Expand Down Expand Up @@ -311,7 +311,7 @@ func Test_Gen_Dao_FieldMapping(t *testing.T) {
filepath.FromSlash(testPath + "/model/do/table_user.go"),
filepath.FromSlash(testPath + "/model/entity/table_user.go"),
}
for i, _ := range files {
for i := range files {
//_ = gfile.PutContents(expectFiles[i], gfile.GetContents(files[i]))
t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i]))
}
Expand Down Expand Up @@ -403,7 +403,7 @@ func Test_Gen_Dao_Sqlite3(t *testing.T) {
filepath.FromSlash(testPath + "/model/do/table_user.go"),
filepath.FromSlash(testPath + "/model/entity/table_user.go"),
}
for i, _ := range files {
for i := range files {
//_ = gfile.PutContents(expectFiles[i], gfile.GetContents(files[i]))
t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i]))
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/gf/internal/cmd/genctrl/genctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ package genctrl
import (
"context"

"github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog"
"github.com/gogf/gf/v2/container/gset"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/util/gtag"

"github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions cmd/gf/internal/cmd/genservice/genservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
"sync"
"sync/atomic"

"github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog"
"github.com/gogf/gf/cmd/gf/v2/internal/utility/utils"
"github.com/gogf/gf/v2/container/garray"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/container/gset"
Expand All @@ -25,6 +23,9 @@ import (
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/util/gtag"

"github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog"
"github.com/gogf/gf/cmd/gf/v2/internal/utility/utils"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions cmd/gf/internal/utility/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import (

"golang.org/x/tools/imports"

"github.com/gogf/gf/cmd/gf/v2/internal/consts"
"github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/os/gproc"
"github.com/gogf/gf/v2/text/gregex"
"github.com/gogf/gf/v2/text/gstr"

"github.com/gogf/gf/cmd/gf/v2/internal/consts"
"github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog"
)

// GoFmt formats the source file and adds or removes import statements as necessary.
Expand Down
8 changes: 2 additions & 6 deletions container/garray/garray_sorted_any.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,9 @@ func (a *SortedArray) Unique() *SortedArray {
if len(a.array) == 0 {
return a
}
i := 0
for {
if i == len(a.array)-1 {
break
}
for i := 0; i < len(a.array)-1; {
if a.getComparator()(a.array[i], a.array[i+1]) == 0 {
a.array = append(a.array[:i+1], a.array[i+1+1:]...)
a.array = append(a.array[:i+1], a.array[i+2:]...)
} else {
i++
}
Expand Down
8 changes: 2 additions & 6 deletions container/garray/garray_sorted_int.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,9 @@ func (a *SortedIntArray) Unique() *SortedIntArray {
if len(a.array) == 0 {
return a
}
i := 0
for {
if i == len(a.array)-1 {
break
}
for i := 0; i < len(a.array)-1; {
if a.getComparator()(a.array[i], a.array[i+1]) == 0 {
a.array = append(a.array[:i+1], a.array[i+1+1:]...)
a.array = append(a.array[:i+1], a.array[i+2:]...)
} else {
i++
}
Expand Down
8 changes: 2 additions & 6 deletions container/garray/garray_sorted_str.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,13 +498,9 @@ func (a *SortedStrArray) Unique() *SortedStrArray {
if len(a.array) == 0 {
return a
}
i := 0
for {
if i == len(a.array)-1 {
break
}
for i := 0; i < len(a.array)-1; {
if a.getComparator()(a.array[i], a.array[i+1]) == 0 {
a.array = append(a.array[:i+1], a.array[i+1+1:]...)
a.array = append(a.array[:i+1], a.array[i+2:]...)
} else {
i++
}
Expand Down
2 changes: 1 addition & 1 deletion container/gmap/gmap_list_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ func (m ListMap) MarshalJSON() (jsonBytes []byte, err error) {
if buffer.Len() > 1 {
buffer.WriteByte(',')
}
buffer.WriteString(fmt.Sprintf(`"%v":%s`, key, valueBytes))
fmt.Fprintf(buffer, `"%v":%s`, key, valueBytes)
return true
})
buffer.WriteByte('}')
Expand Down
5 changes: 1 addition & 4 deletions container/gpool/gpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ func (p *Pool) checkExpireItems(ctx context.Context) {
// by comparing with this timestamp. It is not accurate comparison for
// every item expired, but high performance.
var timestampMilli = gtime.TimestampMilli()
for {
if latestExpire > timestampMilli {
break
}
for latestExpire <= timestampMilli {
if r := p.list.PopFront(); r != nil {
item := r.(*poolItem)
latestExpire = item.expireAt
Expand Down
2 changes: 1 addition & 1 deletion contrib/drivers/mysql/mysql_z_unit_issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ func Test_Issue3968(t *testing.T) {
return nil, err
}
if result != nil {
for i, _ := range result {
for i := range result {
result[i]["location"] = gvar.New("ny")
}
}
Expand Down
13 changes: 4 additions & 9 deletions database/gdb/gdb_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,11 +598,7 @@ func formatWhereHolder(ctx context.Context, db DB, in formatWhereHolderInput) (n
// Regular string and parameter place holder handling.
// Eg:
// Where("id in(?) and name=?", g.Slice{1,2,3}, "john")
i := 0
for {
if i >= len(in.Args) {
break
}
for i := 0; i < len(in.Args); i++ {
// ===============================================================
// Sub query, which is always used along with a string condition.
// ===============================================================
Expand All @@ -621,7 +617,6 @@ func formatWhereHolder(ctx context.Context, db DB, in formatWhereHolderInput) (n
in.Args = gutil.SliceDelete(in.Args, i)
continue
}
i++
}
buffer.WriteString(whereStr)
}
Expand Down Expand Up @@ -858,18 +853,18 @@ func handleSliceAndStructArgsForSql(

// Special struct handling.
case reflect.Struct:
switch oldArg.(type) {
switch v := oldArg.(type) {
// The underlying driver supports time.Time/*time.Time types.
case time.Time, *time.Time:
newArgs = append(newArgs, oldArg)
continue

case gtime.Time:
newArgs = append(newArgs, oldArg.(gtime.Time).Time)
newArgs = append(newArgs, v.Time)
continue

case *gtime.Time:
newArgs = append(newArgs, oldArg.(*gtime.Time).Time)
newArgs = append(newArgs, v.Time)
continue

default:
Expand Down
4 changes: 2 additions & 2 deletions database/gdb/gdb_type_result_scanlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func checkGetSliceElementInfoForScanList(structSlicePointer any, bindToAttrName
}
if reflectKind == reflect.Slice || reflectKind == reflect.Array {
reflectType = reflectType.Elem()
reflectKind = reflectType.Kind()
// reflectKind = reflectType.Kind()
}
out.BindToAttrType = reflectType
return
Expand Down Expand Up @@ -342,7 +342,7 @@ func doScanList(in doScanListInput) (err error) {
arrayElemValue = reflect.New(arrayItemType.Elem()).Elem()
arrayValue.Index(i).Set(arrayElemValue.Addr())
}
} else {
// } else {
// Like: []Entity
}
bindToAttrValue = arrayElemValue.FieldByName(in.BindToAttrName)
Expand Down
16 changes: 8 additions & 8 deletions database/gredis/gredis_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ const errorNilAdapter = `redis adapter is not set, missing configuration or adap
// initGroup initializes the group object of redis.
func (r *Redis) initGroup() *Redis {
r.localGroup = localGroup{
localGroupGeneric: r.localAdapter.GroupGeneric(),
localGroupHash: r.localAdapter.GroupHash(),
localGroupList: r.localAdapter.GroupList(),
localGroupPubSub: r.localAdapter.GroupPubSub(),
localGroupScript: r.localAdapter.GroupScript(),
localGroupSet: r.localAdapter.GroupSet(),
localGroupSortedSet: r.localAdapter.GroupSortedSet(),
localGroupString: r.localAdapter.GroupString(),
localGroupGeneric: r.GroupGeneric(),
localGroupHash: r.GroupHash(),
localGroupList: r.GroupList(),
localGroupPubSub: r.GroupPubSub(),
localGroupScript: r.GroupScript(),
localGroupSet: r.GroupSet(),
localGroupSortedSet: r.GroupSortedSet(),
localGroupString: r.GroupString(),
}
return r
}
Expand Down
2 changes: 1 addition & 1 deletion debug/gdebug/gdebug_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func StackWithFilters(filters []string, skip ...int) string {
if index > 9 {
space = " "
}
buffer.WriteString(fmt.Sprintf("%d.%s%s\n %s:%d\n", index, space, name, file, line))
fmt.Fprintf(buffer, "%d.%s%s\n %s:%d\n", index, space, name, file, line)
index++
} else {
break
Expand Down
4 changes: 2 additions & 2 deletions encoding/gcompress/gcompress_zlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

// Zlib compresses `data` with zlib algorithm.
func Zlib(data []byte) ([]byte, error) {
if data == nil || len(data) < 13 {
if len(data) < 13 {
return data, nil
}
var (
Expand All @@ -39,7 +39,7 @@ func Zlib(data []byte) ([]byte, error) {

// UnZlib decompresses `data` with zlib algorithm.
func UnZlib(data []byte) ([]byte, error) {
if data == nil || len(data) < 13 {
if len(data) < 13 {
return data, nil
}
var (
Expand Down
6 changes: 3 additions & 3 deletions encoding/gini/gini.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,20 @@ func Encode(data map[string]any) (res []byte, err error) {
for section, item := range data {
// Section key-value pairs.
if m, ok = item.(map[string]any); ok {
n, err = w.WriteString(fmt.Sprintf("[%s]\n", section))
n, err = fmt.Fprintf(w, "[%s]\n", section)
if err != nil || n == 0 {
return nil, gerror.Wrapf(err, "w.WriteString failed")
}
for k, v := range m {
if n, err = w.WriteString(fmt.Sprintf("%s=%v\n", k, v)); err != nil || n == 0 {
if n, err = fmt.Fprintf(w, "%s=%v\n", k, v); err != nil || n == 0 {
return nil, gerror.Wrapf(err, "w.WriteString failed")
}
}
continue
}
// Simple key-value pairs.
for k, v := range data {
if n, err = w.WriteString(fmt.Sprintf("%s=%v\n", k, v)); err != nil || n == 0 {
if n, err = fmt.Fprintf(w, "%s=%v\n", k, v); err != nil || n == 0 {
return nil, gerror.Wrapf(err, "w.WriteString failed")
}
}
Expand Down
7 changes: 4 additions & 3 deletions errors/gerror/gerror_error_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func filterLinesOfStackInfos(infos []*stackInfo) {
func formatStackInfos(infos []*stackInfo) string {
buffer := bytes.NewBuffer(nil)
for i, info := range infos {
buffer.WriteString(fmt.Sprintf("%d. %s\n", i+1, info.Message))
fmt.Fprintf(buffer, "%d. %s\n", i+1, info.Message)
if info.Lines != nil && info.Lines.Len() > 0 {
formatStackLines(buffer, info.Lines)
}
Expand All @@ -124,10 +124,11 @@ func formatStackLines(buffer *bytes.Buffer, lines *list.List) string {
if i >= 9 {
space = " "
}
buffer.WriteString(fmt.Sprintf(
fmt.Fprintf(
buffer,
" %d).%s%s\n %s\n",
i+1, space, line.Function, line.FileLine,
))
)
}
return buffer.String()
}
Expand Down
2 changes: 1 addition & 1 deletion net/ghttp/ghttp_middleware_handler_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func MiddlewareHandlerResponse(r *Request) {
r.Middleware.Next()

// There's custom buffer content, it then exits current handler.
if r.Response.BufferLength() > 0 || r.Response.Writer.BytesWritten() > 0 {
if r.Response.BufferLength() > 0 || r.Response.BytesWritten() > 0 {
return
}

Expand Down
2 changes: 1 addition & 1 deletion net/ghttp/ghttp_server_router_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (s *Server) getHandlersWithCache(r *Request) (parsedItems []*HandlerItemPar
// Special http method OPTIONS handling.
// It searches the handler with the request method instead of OPTIONS method.
if method == http.MethodOptions {
if v := r.Request.Header.Get("Access-Control-Request-Method"); v != "" {
if v := r.Header.Get("Access-Control-Request-Method"); v != "" {
method = v
}
}
Expand Down
Loading
Loading