From 0d5dfe59b9df6d742e98a5c7dd31de8053fda070 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 6 Sep 2019 16:44:40 +0800 Subject: [PATCH] remove deprecated functions --- crypto/gcrc32/gcrc32.go | 10 ------ crypto/gsha1/gsha1.go | 6 ---- database/gredis/gredis.go | 8 ----- net/ghttp/ghttp_response.go | 9 ------ net/gtcp/gtcp_func.go | 10 ------ os/gcfg/gcfg.go | 6 ---- os/gcfg/gcfg_api.go | 5 --- os/gfile/gfile_contents.go | 44 +-------------------------- os/gfpool/gfpool.go | 6 ---- os/gfpool/gfpool_z_unit_test.go | 13 -------- os/glog/glog_api.go | 54 --------------------------------- os/glog/glog_logger_api.go | 54 --------------------------------- os/glog/glog_logger_chaining.go | 6 ---- os/gtime/gtime_time.go | 6 ---- test/gtest/gtest.go | 15 ++------- util/grand/grand.go | 24 --------------- 16 files changed, 3 insertions(+), 273 deletions(-) diff --git a/crypto/gcrc32/gcrc32.go b/crypto/gcrc32/gcrc32.go index e18e01e73..5ef54cbca 100644 --- a/crypto/gcrc32/gcrc32.go +++ b/crypto/gcrc32/gcrc32.go @@ -18,13 +18,3 @@ import ( func Encrypt(v interface{}) uint32 { return crc32.ChecksumIEEE(gconv.Bytes(v)) } - -// Deprecated. -func EncryptString(v string) uint32 { - return crc32.ChecksumIEEE([]byte(v)) -} - -// Deprecated. -func EncryptBytes(v []byte) uint32 { - return crc32.ChecksumIEEE(v) -} diff --git a/crypto/gsha1/gsha1.go b/crypto/gsha1/gsha1.go index 7b0e28370..8a84f45b0 100644 --- a/crypto/gsha1/gsha1.go +++ b/crypto/gsha1/gsha1.go @@ -24,12 +24,6 @@ func Encrypt(v interface{}) string { return hex.EncodeToString(r[:]) } -// EncryptString is alias of Encrypt. -// Deprecated. -func EncryptString(s string) string { - return Encrypt(s) -} - // EncryptFile encrypts file content of using SHA1 algorithms. func EncryptFile(path string) (encrypt string, err error) { f, err := os.Open(path) diff --git a/database/gredis/gredis.go b/database/gredis/gredis.go index 083607197..eb679fb42 100644 --- a/database/gredis/gredis.go +++ b/database/gredis/gredis.go @@ -167,11 +167,3 @@ func (r *Redis) DoVar(command string, args ...interface{}) (*gvar.Var, error) { v, err := r.Do(command, args...) return gvar.New(v), err } - -// Deprecated. -// Send writes the command to the client's output buffer. -func (r *Redis) Send(command string, args ...interface{}) error { - conn := &Conn{r.pool.Get()} - defer conn.Close() - return conn.Send(command, args...) -} diff --git a/net/ghttp/ghttp_response.go b/net/ghttp/ghttp_response.go index f86a8f08e..1c6cd3f29 100644 --- a/net/ghttp/ghttp_response.go +++ b/net/ghttp/ghttp_response.go @@ -234,15 +234,6 @@ func (r *Response) ClearBuffer() { r.buffer.Reset() } -// Deprecated. -// -// 输出缓冲区数据到客户端. -func (r *Response) OutputBuffer() { - r.Header().Set("Server", r.Server.config.ServerAgent) - //r.handleGzip() - r.Writer.OutputBuffer() -} - // 输出缓冲区数据到客户端. func (r *Response) Output() { r.Header().Set("Server", r.Server.config.ServerAgent) diff --git a/net/gtcp/gtcp_func.go b/net/gtcp/gtcp_func.go index c2743c0f2..8a82a3c35 100644 --- a/net/gtcp/gtcp_func.go +++ b/net/gtcp/gtcp_func.go @@ -25,16 +25,6 @@ type Retry struct { Interval int // 重试间隔(毫秒) } -// Deprecated. -// 常见的二进制数据校验方式,生成校验结果 -func Checksum(buffer []byte) uint32 { - var checksum uint32 - for _, b := range buffer { - checksum += uint32(b) - } - return checksum -} - // 创建原生TCP链接, addr地址格式形如:127.0.0.1:80 func NewNetConn(addr string, timeout ...int) (net.Conn, error) { if len(timeout) > 0 { diff --git a/os/gcfg/gcfg.go b/os/gcfg/gcfg.go index 918bfdd65..16078e8ad 100644 --- a/os/gcfg/gcfg.go +++ b/os/gcfg/gcfg.go @@ -243,12 +243,6 @@ func (c *Config) AddPath(path string) error { return nil } -// GetFilePath is alias of FilePath. -// Deprecated. -func (c *Config) GetFilePath(file ...string) (path string) { - return c.FilePath(file...) -} - // GetFilePath returns the absolute path of the specified configuration file. // If is not passed, it returns the configuration file path of the default name. // If the specified configuration file does not exist, diff --git a/os/gcfg/gcfg_api.go b/os/gcfg/gcfg_api.go index 81d61f1c8..6de357088 100644 --- a/os/gcfg/gcfg_api.go +++ b/os/gcfg/gcfg_api.go @@ -282,11 +282,6 @@ func (c *Config) GetMapStructsDeep(pattern string, pointer interface{}, mapping return errors.New("configuration not found") } -// Deprecated. -func (c *Config) GetToStruct(pattern string, pointer interface{}) error { - return c.GetStruct(pattern, pointer) -} - func (c *Config) ToMap() map[string]interface{} { if j := c.getJson(); j != nil { return j.ToMap() diff --git a/os/gfile/gfile_contents.go b/os/gfile/gfile_contents.go index cdecb44d5..96bdd7d66 100644 --- a/os/gfile/gfile_contents.go +++ b/os/gfile/gfile_contents.go @@ -23,12 +23,6 @@ func GetContents(path string) string { return string(GetBytes(path)) } -// GetBinContents is alias of GetBytes. -// Deprecated. -func GetBinContents(path string) []byte { - return GetBytes(path) -} - // GetBytes returns the file content of as []byte. // It returns nil if it fails reading. func GetBytes(path string) []byte { @@ -79,24 +73,12 @@ func PutContentsAppend(path string, content string) error { return putContents(path, []byte(content), os.O_WRONLY|os.O_CREATE|os.O_APPEND, gDEFAULT_PERM) } -// PutBinContents is alias of PutBytes. -// Deprecated. -func PutBinContents(path string, content []byte) error { - return PutBytes(path, content) -} - // PutBytes puts binary to file of . // It creates file of recursively if it does not exist. func PutBytes(path string, content []byte) error { return putContents(path, content, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, gDEFAULT_PERM) } -// PutBinContentsAppend is alias of PutBytesAppend. -// Deprecated. -func PutBinContentsAppend(path string, content []byte) error { - return PutBytesAppend(path, content) -} - // PutBytesAppend appends binary to file of . // It creates file of recursively if it does not exist. func PutBytesAppend(path string, content []byte) error { @@ -132,12 +114,6 @@ func GetNextCharOffsetByPath(path string, char byte, start int64) int64 { return -1 } -// GetBinContentsTilChar is alias of GetBytesTilChar. -// Deprecated. -func GetBinContentsTilChar(reader io.ReaderAt, char byte, start int64) ([]byte, int64) { - return GetBytesTilChar(reader, char, start) -} - // GetBytesTilChar returns the contents of the file as []byte // until the next specified byte position. // @@ -149,12 +125,6 @@ func GetBytesTilChar(reader io.ReaderAt, char byte, start int64) ([]byte, int64) return nil, -1 } -// GetBinContentsTilCharByPath is alias of GetBytesTilCharByPath. -// Deprecated. -func GetBinContentsTilCharByPath(path string, char byte, start int64) ([]byte, int64) { - return GetBytesTilCharByPath(path, char, start) -} - // GetBytesTilCharByPath returns the contents of the file given by as []byte // until the next specified byte position. // It opens file of for reading with os.O_RDONLY flag and default perm. @@ -168,12 +138,6 @@ func GetBytesTilCharByPath(path string, char byte, start int64) ([]byte, int64) return nil, -1 } -// GetBinContentsByTwoOffsets is alias of GetBytesByTwoOffsets. -// Deprecated. -func GetBinContentsByTwoOffsets(reader io.ReaderAt, start int64, end int64) []byte { - return GetBytesByTwoOffsets(reader, start, end) -} - // GetBytesByTwoOffsets returns the binary content as []byte from to . // Note: Returned value does not contain the character of the last position, which means // it returns content range as [start, end). @@ -185,12 +149,6 @@ func GetBytesByTwoOffsets(reader io.ReaderAt, start int64, end int64) []byte { return buffer } -// GetBinContentsByTwoOffsetsByPath is alias of GetBytesByTwoOffsetsByPath. -// Deprecated. -func GetBinContentsByTwoOffsetsByPath(path string, start int64, end int64) []byte { - return GetBytesByTwoOffsetsByPath(path, start, end) -} - // GetBytesByTwoOffsetsByPath returns the binary content as []byte from to . // Note: Returned value does not contain the character of the last position, which means // it returns content range as [start, end). @@ -198,7 +156,7 @@ func GetBinContentsByTwoOffsetsByPath(path string, start int64, end int64) []byt func GetBytesByTwoOffsetsByPath(path string, start int64, end int64) []byte { if f, err := OpenWithFlagPerm(path, os.O_RDONLY, gDEFAULT_PERM); err == nil { defer f.Close() - return GetBinContentsByTwoOffsets(f, start, end) + return GetBytesByTwoOffsets(f, start, end) } return nil } diff --git a/os/gfpool/gfpool.go b/os/gfpool/gfpool.go index 493783f82..caae3486e 100644 --- a/os/gfpool/gfpool.go +++ b/os/gfpool/gfpool.go @@ -55,12 +55,6 @@ func Open(path string, flag int, perm os.FileMode, expire ...int) (file *File, e return pool.File() } -// Deprecated. -// See Open. -func OpenFile(path string, flag int, perm os.FileMode, expire ...int) (file *File, err error) { - return Open(path, flag, perm, expire...) -} - // 创建一个文件指针池,expire = 0表示不过期,expire < 0表示使用完立即回收,expire > 0表示超时回收,默认值为0表示不过期。 // 注意过期时间单位为:毫秒。 func New(path string, flag int, perm os.FileMode, expire ...int) *Pool { diff --git a/os/gfpool/gfpool_z_unit_test.go b/os/gfpool/gfpool_z_unit_test.go index 9730954c2..3bfa7f7c0 100644 --- a/os/gfpool/gfpool_z_unit_test.go +++ b/os/gfpool/gfpool_z_unit_test.go @@ -24,13 +24,6 @@ func TestOpen(t *testing.T) { gtest.AssertEQ(err1, nil) gtest.AssertEQ(f, f2) f2.Close() - - // Deprecated test - f3, err2 := gfpool.OpenFile(testFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0666) - gtest.AssertEQ(err2, nil) - gtest.AssertEQ(f, f3) - f3.Close() - }) stop(testFile) @@ -95,12 +88,6 @@ func TestOpenExpire(t *testing.T) { gtest.AssertEQ(err1, nil) //gtest.AssertNE(f, f2) f2.Close() - - // Deprecated test - f3, err2 := gfpool.Open(testFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0666, 100) - gtest.AssertEQ(err2, nil) - gtest.AssertEQ(f2, f3) - f3.Close() }) stop(testFile) diff --git a/os/glog/glog_api.go b/os/glog/glog_api.go index 52c9bfb1d..8cc66a442 100644 --- a/os/glog/glog_api.go +++ b/os/glog/glog_api.go @@ -23,12 +23,6 @@ func Println(v ...interface{}) { logger.Println(v...) } -// Deprecated. -// Use Printf instead. -func Printfln(format string, v ...interface{}) { - logger.Printfln(format, v...) -} - // Fatal prints the logging content with [FATA] header and newline, then exit the current process. func Fatal(v ...interface{}) { logger.Fatal(v...) @@ -39,12 +33,6 @@ func Fatalf(format string, v ...interface{}) { logger.Fatalf(format, v...) } -// Deprecated. -// Use Fatalf instead. -func Fatalfln(format string, v ...interface{}) { - logger.Fatalfln(format, v...) -} - // Panic prints the logging content with [PANI] header and newline, then panics. func Panic(v ...interface{}) { logger.Panic(v...) @@ -55,12 +43,6 @@ func Panicf(format string, v ...interface{}) { logger.Panicf(format, v...) } -// Deprecated. -// Use Panicf instead. -func Panicfln(format string, v ...interface{}) { - logger.Panicfln(format, v...) -} - // Info prints the logging content with [INFO] header and newline. func Info(v ...interface{}) { logger.Info(v...) @@ -71,12 +53,6 @@ func Infof(format string, v ...interface{}) { logger.Infof(format, v...) } -// Deprecated. -// Use Infof instead. -func Infofln(format string, v ...interface{}) { - logger.Infofln(format, v...) -} - // Debug prints the logging content with [DEBU] header and newline. func Debug(v ...interface{}) { logger.Debug(v...) @@ -87,12 +63,6 @@ func Debugf(format string, v ...interface{}) { logger.Debugf(format, v...) } -// Deprecated. -// Use Debugf instead. -func Debugfln(format string, v ...interface{}) { - logger.Debugfln(format, v...) -} - // Notice prints the logging content with [NOTI] header and newline. // It also prints caller stack info if stack feature is enabled. func Notice(v ...interface{}) { @@ -105,12 +75,6 @@ func Noticef(format string, v ...interface{}) { logger.Noticef(format, v...) } -// Deprecated. -// Use Noticef instead. -func Noticefln(format string, v ...interface{}) { - logger.Noticefln(format, v...) -} - // Warning prints the logging content with [WARN] header and newline. // It also prints caller stack info if stack feature is enabled. func Warning(v ...interface{}) { @@ -123,12 +87,6 @@ func Warningf(format string, v ...interface{}) { logger.Warningf(format, v...) } -// Deprecated. -// Use Warningf instead. -func Warningfln(format string, v ...interface{}) { - logger.Warningfln(format, v...) -} - // Error prints the logging content with [ERRO] header and newline. // It also prints caller stack info if stack feature is enabled. func Error(v ...interface{}) { @@ -141,12 +99,6 @@ func Errorf(format string, v ...interface{}) { logger.Errorf(format, v...) } -// Deprecated. -// Use Errorf instead. -func Errorfln(format string, v ...interface{}) { - logger.Errorfln(format, v...) -} - // Critical prints the logging content with [CRIT] header and newline. // It also prints caller stack info if stack feature is enabled. func Critical(v ...interface{}) { @@ -158,9 +110,3 @@ func Critical(v ...interface{}) { func Criticalf(format string, v ...interface{}) { logger.Criticalf(format, v...) } - -// Deprecated. -// Use Criticalf instead. -func Criticalfln(format string, v ...interface{}) { - logger.Criticalfln(format, v...) -} diff --git a/os/glog/glog_logger_api.go b/os/glog/glog_logger_api.go index b86fe2e2f..b6bb2b887 100644 --- a/os/glog/glog_logger_api.go +++ b/os/glog/glog_logger_api.go @@ -28,12 +28,6 @@ func (l *Logger) Println(v ...interface{}) { l.Print(v...) } -// Deprecated. -// Use Printf instead. -func (l *Logger) Printfln(format string, v ...interface{}) { - l.Printf(format, v...) -} - // Fatal prints the logging content with [FATA] header and newline, then exit the current process. func (l *Logger) Fatal(v ...interface{}) { l.printErr("[FATA]", v...) @@ -46,12 +40,6 @@ func (l *Logger) Fatalf(format string, v ...interface{}) { os.Exit(1) } -// Deprecated. -// Use Fatalf instead. -func (l *Logger) Fatalfln(format string, v ...interface{}) { - l.Fatalf(format, v...) -} - // Panic prints the logging content with [PANI] header and newline, then panics. func (l *Logger) Panic(v ...interface{}) { l.printErr("[PANI]", v...) @@ -64,12 +52,6 @@ func (l *Logger) Panicf(format string, v ...interface{}) { panic(l.format(format, v...)) } -// Deprecated. -// Use Panicf instead. -func (l *Logger) Panicfln(format string, v ...interface{}) { - l.Panicf(format, v...) -} - // Info prints the logging content with [INFO] header and newline. func (l *Logger) Info(v ...interface{}) { if l.checkLevel(LEVEL_INFO) { @@ -84,12 +66,6 @@ func (l *Logger) Infof(format string, v ...interface{}) { } } -// Deprecated. -// Use Infof instead. -func (l *Logger) Infofln(format string, v ...interface{}) { - l.Infof(format, v...) -} - // Debug prints the logging content with [DEBU] header and newline. func (l *Logger) Debug(v ...interface{}) { if l.checkLevel(LEVEL_DEBU) { @@ -104,12 +80,6 @@ func (l *Logger) Debugf(format string, v ...interface{}) { } } -// Deprecated. -// Use Debugf instead. -func (l *Logger) Debugfln(format string, v ...interface{}) { - l.Debugf(format, v...) -} - // Notice prints the logging content with [NOTI] header and newline. // It also prints caller stack info if stack feature is enabled. func (l *Logger) Notice(v ...interface{}) { @@ -126,12 +96,6 @@ func (l *Logger) Noticef(format string, v ...interface{}) { } } -// Deprecated. -// Use Noticef instead. -func (l *Logger) Noticefln(format string, v ...interface{}) { - l.Noticef(format, v...) -} - // Warning prints the logging content with [WARN] header and newline. // It also prints caller stack info if stack feature is enabled. func (l *Logger) Warning(v ...interface{}) { @@ -148,12 +112,6 @@ func (l *Logger) Warningf(format string, v ...interface{}) { } } -// Deprecated. -// Use Warningf instead. -func (l *Logger) Warningfln(format string, v ...interface{}) { - l.Warningf(format, v...) -} - // Error prints the logging content with [ERRO] header and newline. // It also prints caller stack info if stack feature is enabled. func (l *Logger) Error(v ...interface{}) { @@ -170,12 +128,6 @@ func (l *Logger) Errorf(format string, v ...interface{}) { } } -// Deprecated. -// Use Errorf instead. -func (l *Logger) Errorfln(format string, v ...interface{}) { - l.Errorf(format, v...) -} - // Critical prints the logging content with [CRIT] header and newline. // It also prints caller stack info if stack feature is enabled. func (l *Logger) Critical(v ...interface{}) { @@ -192,12 +144,6 @@ func (l *Logger) Criticalf(format string, v ...interface{}) { } } -// Deprecated. -// Use Criticalf instead. -func (l *Logger) Criticalfln(format string, v ...interface{}) { - l.Criticalf(format, v...) -} - // checkLevel checks whether the given could be output. func (l *Logger) checkLevel(level int) bool { return l.level&level > 0 diff --git a/os/glog/glog_logger_chaining.go b/os/glog/glog_logger_chaining.go index 96c8c8b65..95ed71782 100644 --- a/os/glog/glog_logger_chaining.go +++ b/os/glog/glog_logger_chaining.go @@ -145,12 +145,6 @@ func (l *Logger) Stdout(enabled ...bool) *Logger { return logger } -// See Stdout. -// Deprecated. -func (l *Logger) StdPrint(enabled ...bool) *Logger { - return l.Stdout(enabled...) -} - // Header is a chaining function, // which enables/disables log header for the current logging content output. // It's enabled in default. diff --git a/os/gtime/gtime_time.go b/os/gtime/gtime_time.go index 03912a96e..59fca22a4 100644 --- a/os/gtime/gtime_time.go +++ b/os/gtime/gtime_time.go @@ -100,12 +100,6 @@ func (t *Time) String() string { return t.Format("Y-m-d H:i:s") } -// Deprecated. -// Directly use t.Time instead. -func (t *Time) ToTime() time.Time { - return t.Time -} - // 复制当前时间对象 func (t *Time) Clone() *Time { return New(t.Time) diff --git a/test/gtest/gtest.go b/test/gtest/gtest.go index 4c297c590..fefeb275c 100644 --- a/test/gtest/gtest.go +++ b/test/gtest/gtest.go @@ -9,11 +9,12 @@ package gtest import ( "fmt" - "github.com/gogf/gf/debug/gdebug" "os" "reflect" "testing" + "github.com/gogf/gf/debug/gdebug" + "github.com/gogf/gf/util/gconv" ) @@ -121,12 +122,6 @@ func AssertGT(value, expect interface{}) { } } -// Deprecated. -// See AssertGE. -func AssertGTE(value, expect interface{}) { - AssertGE(value, expect) -} - // AssertGE checks is GREATER OR EQUAL THAN . // Notice that, only string, integer and float types can be compared by AssertGTE, // others are invalid. @@ -173,12 +168,6 @@ func AssertLT(value, expect interface{}) { } } -// Deprecated. -// See AssertLE. -func AssertLTE(value, expect interface{}) { - AssertLE(value, expect) -} - // AssertLE checks is LESS OR EQUAL THAN . // Notice that, only string, integer and float types can be compared by AssertLTE, // others are invalid. diff --git a/util/grand/grand.go b/util/grand/grand.go index 9b49b9fd8..bcf335642 100644 --- a/util/grand/grand.go +++ b/util/grand/grand.go @@ -45,12 +45,6 @@ func N(min, max int) int { return 0 } -// Deprecated. -// Alias of N. -func Rand(min, max int) int { - return N(min, max) -} - // Str returns a random string which contains digits and letters, and its length is . func Str(n int) string { b := make([]rune, n) @@ -64,12 +58,6 @@ func Str(n int) string { return string(b) } -// Deprecated. -// Alias of Str. -func RandStr(n int) string { - return Str(n) -} - // Digits returns a random string which contains only digits, and its length is . func Digits(n int) string { b := make([]rune, n) @@ -79,12 +67,6 @@ func Digits(n int) string { return string(b) } -// Deprecated. -// Alias of Digits. -func RandDigits(n int) string { - return Digits(n) -} - // Letters returns a random string which contains only letters, and its length is . func Letters(n int) string { b := make([]rune, n) @@ -95,12 +77,6 @@ func Letters(n int) string { } -// Deprecated. -// Alias of Letters. -func RandLetters(n int) string { - return Letters(n) -} - // Perm returns, as a slice of n int numbers, a pseudo-random permutation of the integers [0,n). func Perm(n int) []int { m := make([]int, n)