diff --git a/.example/os/gfsnotify/fsnotify.go b/.example/os/gfsnotify/fsnotify.go index 833732398..729fcd1b9 100644 --- a/.example/os/gfsnotify/fsnotify.go +++ b/.example/os/gfsnotify/fsnotify.go @@ -5,6 +5,7 @@ import ( "log" "github.com/fsnotify/fsnotify" + "github.com/gogf/gf/v2/os/glog" ) @@ -15,13 +16,13 @@ func main() { log.Fatal(err) } defer watch.Close() - //添加要监控的对象,文件或文件夹 - //err = watch.Add("D:\\Workspace\\Go\\GOPATH\\src\\gitee.com\\johng\\gf\\geg\\other\\test.go") + // 添加要监控的对象,文件或文件夹 + // err = watch.Add("D:\\Workspace\\Go\\GOPATH\\src\\gitee.com\\johng\\gf\\geg\\other\\test.go") err = watch.Add("/Users/john/Workspace/Go/GOPATH/src/github.com/gogf/gf/.example/other/test.go") if err != nil { log.Fatal(err) } - //我们另启一个goroutine来处理监控对象的事件 + // 我们另启一个goroutine来处理监控对象的事件 go func() { for { select { @@ -36,6 +37,6 @@ func main() { } }() - //循环 + // 循环 select {} } diff --git a/.golangci.yml b/.golangci.yml index 5e63d73e6..511d6b8c3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -723,7 +723,7 @@ linters-settings: max-distance: 5 # The minimum length of a variable's name that is considered "long." (defaults to 3) # Variable names that are at least this long will be ignored. - min-name-length: 3 + min-name-length: 1 # Check method receiver names. (defaults to false) check-receiver: false # Check named return values. (defaults to false) diff --git a/database/gredis/gredis_adapter_goredis.go b/database/gredis/gredis_adapter_goredis.go index 4081b7037..ed5c3feae 100644 --- a/database/gredis/gredis_adapter_goredis.go +++ b/database/gredis/gredis_adapter_goredis.go @@ -11,6 +11,7 @@ import ( "time" "github.com/go-redis/redis/v8" + "github.com/gogf/gf/v2/text/gstr" ) diff --git a/database/gredis/gredis_adapter_goredis_conn.go b/database/gredis/gredis_adapter_goredis_conn.go index 36e32223f..a4a1bd243 100644 --- a/database/gredis/gredis_adapter_goredis_conn.go +++ b/database/gredis/gredis_adapter_goredis_conn.go @@ -10,6 +10,7 @@ import ( "context" "github.com/go-redis/redis/v8" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" diff --git a/encoding/gbinary/gbinary_bit.go b/encoding/gbinary/gbinary_bit.go index e382fecea..3e93dcab6 100644 --- a/encoding/gbinary/gbinary_bit.go +++ b/encoding/gbinary/gbinary_bit.go @@ -8,19 +8,16 @@ package gbinary // NOTE: THIS IS AN EXPERIMENTAL FEATURE! -// Bit Binary bit (0 | 1) 二进制位(0|1) +// Bit Binary bit (0 | 1) type Bit int8 -// EncodeBits . -// Default coding -// 默认编码 +// EncodeBits does encode bits return bits Default coding func EncodeBits(bits []Bit, i int, l int) []Bit { return EncodeBitsWithUint(bits, uint(i), l) } -// EncodeBitsWithUint . -// Merge ui bitwise into the bits array and occupy the length length bits (Note: binary 0 | 1 digits are stored in the uis array) -// 将ui按位合并到bits数组中,并占length长度位(注意:uis数组中存放的是二进制的0|1数字) +// EncodeBitsWithUint . Merge ui bitwise into the bits array and occupy the length bits +// (Note: binary 0 | 1 digits are stored in the uis array) func EncodeBitsWithUint(bits []Bit, ui uint, l int) []Bit { a := make([]Bit, l) for i := l - 1; i >= 0; i-- { @@ -33,9 +30,8 @@ func EncodeBitsWithUint(bits []Bit, ui uint, l int) []Bit { return a } -// EncodeBitsToBytes . +// EncodeBitsToBytes . does encode bits to bytes // Convert bits to [] byte, encode from left to right, and add less than 1 byte from 0 to the end. -// 将bits转换为[]byte,从左至右进行编码,不足1 byte按0往末尾补充 func EncodeBitsToBytes(bits []Bit) []byte { if len(bits)%8 != 0 { for i := 0; i < len(bits)%8; i++ { @@ -49,9 +45,8 @@ func EncodeBitsToBytes(bits []Bit) []byte { return b } -// DecodeBits . +// DecodeBits .does decode bits to int // Resolve to int -// 解析为int func DecodeBits(bits []Bit) int { v := 0 for _, i := range bits { @@ -60,9 +55,7 @@ func DecodeBits(bits []Bit) int { return v } -// DecodeBitsToUint . -// Resolve to uint -// 解析为uint +// DecodeBitsToUint .Resolve to uint func DecodeBitsToUint(bits []Bit) uint { v := uint(0) for _, i := range bits { @@ -71,9 +64,7 @@ func DecodeBitsToUint(bits []Bit) uint { return v } -// DecodeBytesToBits . -// Parsing [] byte into character array [] uint8 -// 解析[]byte为字位数组[]uint8 +// DecodeBytesToBits .Parsing [] byte into character array [] uint8 func DecodeBytesToBits(bs []byte) []Bit { bits := make([]Bit, 0) for _, b := range bs { diff --git a/encoding/gcharset/gcharset.go b/encoding/gcharset/gcharset.go index 534f84aa3..bd283bc56 100644 --- a/encoding/gcharset/gcharset.go +++ b/encoding/gcharset/gcharset.go @@ -24,12 +24,13 @@ import ( "context" "io/ioutil" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/intlog" "golang.org/x/text/encoding" "golang.org/x/text/encoding/ianaindex" "golang.org/x/text/transform" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/intlog" ) var ( diff --git a/encoding/gyaml/gyaml.go b/encoding/gyaml/gyaml.go index 4a9cbe234..143834dc0 100644 --- a/encoding/gyaml/gyaml.go +++ b/encoding/gyaml/gyaml.go @@ -8,10 +8,11 @@ package gyaml import ( + "gopkg.in/yaml.v3" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/util/gconv" - "gopkg.in/yaml.v3" ) func Encode(value interface{}) (out []byte, err error) { diff --git a/net/gtrace/gtrace.go b/net/gtrace/gtrace.go index f64bc621b..846cefb47 100644 --- a/net/gtrace/gtrace.go +++ b/net/gtrace/gtrace.go @@ -12,14 +12,15 @@ import ( "os" "strings" - "github.com/gogf/gf/v2/container/gmap" - "github.com/gogf/gf/v2/container/gvar" - "github.com/gogf/gf/v2/net/gipv4" - "github.com/gogf/gf/v2/os/gcmd" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" + + "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/container/gvar" + "github.com/gogf/gf/v2/net/gipv4" + "github.com/gogf/gf/v2/os/gcmd" ) const ( diff --git a/net/gtrace/gtrace_baggage.go b/net/gtrace/gtrace_baggage.go index dd7a0dfb4..26a9eb86a 100644 --- a/net/gtrace/gtrace_baggage.go +++ b/net/gtrace/gtrace_baggage.go @@ -9,10 +9,11 @@ package gtrace import ( "context" + "go.opentelemetry.io/otel/baggage" + "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/util/gconv" - "go.opentelemetry.io/otel/baggage" ) // Baggage holds the data through all tracing spans. diff --git a/net/gtrace/gtrace_unit_carrier_test.go b/net/gtrace/gtrace_unit_carrier_test.go index 24262222f..d3fecf225 100644 --- a/net/gtrace/gtrace_unit_carrier_test.go +++ b/net/gtrace/gtrace_unit_carrier_test.go @@ -10,10 +10,11 @@ import ( "context" "testing" - "github.com/gogf/gf/v2/net/gtrace" - "github.com/gogf/gf/v2/test/gtest" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/trace" + + "github.com/gogf/gf/v2/net/gtrace" + "github.com/gogf/gf/v2/test/gtest" ) const ( diff --git a/os/gfsnotify/gfsnotify.go b/os/gfsnotify/gfsnotify.go index 12235ae61..b6de60e0e 100644 --- a/os/gfsnotify/gfsnotify.go +++ b/os/gfsnotify/gfsnotify.go @@ -13,6 +13,7 @@ import ( "time" "github.com/fsnotify/fsnotify" + "github.com/gogf/gf/v2/container/glist" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/container/gqueue" diff --git a/os/glog/glog_logger.go b/os/glog/glog_logger.go index 178c5828b..0190e3f09 100644 --- a/os/glog/glog_logger.go +++ b/os/glog/glog_logger.go @@ -16,6 +16,8 @@ import ( "time" "github.com/fatih/color" + "go.opentelemetry.io/otel/trace" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/internal/intlog" @@ -27,7 +29,6 @@ import ( "github.com/gogf/gf/v2/os/gtimer" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/util/gconv" - "go.opentelemetry.io/otel/trace" ) // Logger is the struct for logging management.