[feature] improve code gview

This commit is contained in:
houseme
2021-11-15 20:49:02 +08:00
parent cd60a4aca7
commit 4fa2a879d7
50 changed files with 150 additions and 138 deletions

View File

@ -16,7 +16,7 @@ import (
)
func Test_Locker_RLock(t *testing.T) {
//RLock before Lock
// RLock before Lock
gtest.C(t, func(t *gtest.T) {
key := "testRLockBeforeLock"
array := garray.New(true)
@ -38,7 +38,7 @@ func Test_Locker_RLock(t *testing.T) {
t.Assert(array.Len(), 2)
})
//Lock before RLock
// Lock before RLock
gtest.C(t, func(t *gtest.T) {
key := "testLockBeforeRLock"
array := garray.New(true)
@ -60,7 +60,7 @@ func Test_Locker_RLock(t *testing.T) {
t.Assert(array.Len(), 2)
})
//Lock before RLocks
// Lock before RLocks
gtest.C(t, func(t *gtest.T) {
key := "testLockBeforeRLocks"
array := garray.New(true)
@ -92,7 +92,7 @@ func Test_Locker_RLock(t *testing.T) {
}
func Test_Locker_TryRLock(t *testing.T) {
//Lock before TryRLock
// Lock before TryRLock
gtest.C(t, func(t *gtest.T) {
key := "testLockBeforeTryRLock"
array := garray.New(true)
@ -115,7 +115,7 @@ func Test_Locker_TryRLock(t *testing.T) {
t.Assert(array.Len(), 1)
})
//Lock before TryRLocks
// Lock before TryRLocks
gtest.C(t, func(t *gtest.T) {
key := "testLockBeforeTryRLocks"
array := garray.New(true)
@ -147,7 +147,7 @@ func Test_Locker_TryRLock(t *testing.T) {
}
func Test_Locker_RLockFunc(t *testing.T) {
//RLockFunc before Lock
// RLockFunc before Lock
gtest.C(t, func(t *gtest.T) {
key := "testRLockFuncBeforeLock"
array := garray.New(true)
@ -169,7 +169,7 @@ func Test_Locker_RLockFunc(t *testing.T) {
t.Assert(array.Len(), 2)
})
//Lock before RLockFunc
// Lock before RLockFunc
gtest.C(t, func(t *gtest.T) {
key := "testLockBeforeRLockFunc"
array := garray.New(true)
@ -191,7 +191,7 @@ func Test_Locker_RLockFunc(t *testing.T) {
t.Assert(array.Len(), 2)
})
//Lock before RLockFuncs
// Lock before RLockFuncs
gtest.C(t, func(t *gtest.T) {
key := "testLockBeforeRLockFuncs"
array := garray.New(true)
@ -223,7 +223,7 @@ func Test_Locker_RLockFunc(t *testing.T) {
}
func Test_Locker_TryRLockFunc(t *testing.T) {
//Lock before TryRLockFunc
// Lock before TryRLockFunc
gtest.C(t, func(t *gtest.T) {
key := "testLockBeforeTryRLockFunc"
array := garray.New(true)
@ -245,7 +245,7 @@ func Test_Locker_TryRLockFunc(t *testing.T) {
t.Assert(array.Len(), 1)
})
//Lock before TryRLockFuncs
// Lock before TryRLockFuncs
gtest.C(t, func(t *gtest.T) {
key := "testLockBeforeTryRLockFuncs"
array := garray.New(true)

View File

@ -7,8 +7,9 @@
package gmlock_test
import (
"github.com/gogf/gf/v2/os/gmlock"
"testing"
"github.com/gogf/gf/v2/os/gmlock"
)
var (

View File

@ -14,7 +14,7 @@ import (
"github.com/gogf/gf/v2/container/gtype"
)
// The high level Mutex, which implements more rich features for mutex.
// Mutex The high level Mutex, which implements more rich features for mutex.
type Mutex struct {
state *gtype.Int32 // Indicates the state of mutex. -1: writing locked; > 1 reading locked.
writer *gtype.Int32 // Pending writer count.

View File

@ -8,11 +8,11 @@ package gmutex_test
import (
"context"
"github.com/gogf/gf/v2/os/glog"
"testing"
"time"
"github.com/gogf/gf/v2/container/garray"
"github.com/gogf/gf/v2/os/glog"
"github.com/gogf/gf/v2/os/gmutex"
"github.com/gogf/gf/v2/test/gtest"
)
@ -41,7 +41,7 @@ func Test_Mutex_RUnlock(t *testing.T) {
})
//RLock before Lock
// RLock before Lock
gtest.C(t, func(t *gtest.T) {
mu := gmutex.New()
mu.RLock()

View File

@ -9,14 +9,14 @@ package gproc
import (
"bytes"
"github.com/gogf/gf/v2/os/genv"
"github.com/gogf/gf/v2/text/gstr"
"io"
"os"
"runtime"
"time"
"github.com/gogf/gf/v2/os/genv"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
)

View File

@ -9,6 +9,7 @@ package gproc
import (
"context"
"fmt"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"

View File

@ -9,11 +9,11 @@ package gproc
import (
"context"
"fmt"
"github.com/gogf/gf/v2/internal/json"
"net"
"github.com/gogf/gf/v2/container/gqueue"
"github.com/gogf/gf/v2/container/gtype"
"github.com/gogf/gf/v2/internal/json"
"github.com/gogf/gf/v2/net/gtcp"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/os/glog"
@ -94,7 +94,7 @@ func receiveTcpHandler(conn *gtcp.Conn) {
// Package decoding.
msg := new(MsgRequest)
if err := json.UnmarshalUseNumber(buffer, msg); err != nil {
//glog.Error(err)
// glog.Error(err)
continue
}
if msg.RecvPid != Pid() {

View File

@ -7,10 +7,11 @@
package gproc
import (
"io"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/json"
"github.com/gogf/gf/v2/net/gtcp"
"io"
)
// Send sends data to specified process of given pid.

View File

@ -9,13 +9,14 @@ package gproc
import (
"context"
"fmt"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
"os"
"os/exec"
"runtime"
"strings"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
)
// Process is the struct for a single process.
@ -123,7 +124,7 @@ func (p *Process) Kill() error {
}
_, err = p.Process.Wait()
intlog.Error(context.TODO(), err)
//return err
// return err
return nil
} else {
return err

View File

@ -8,11 +8,12 @@ package gproc
import (
"context"
"github.com/gogf/gf/v2/internal/intlog"
"os"
"os/signal"
"sync"
"syscall"
"github.com/gogf/gf/v2/internal/intlog"
)
// SigHandler defines a function type for signal handling.

View File

@ -9,9 +9,10 @@ package gres
import (
"archive/zip"
"bytes"
"github.com/gogf/gf/v2/internal/json"
"io"
"os"
"github.com/gogf/gf/v2/internal/json"
)
type File struct {

View File

@ -11,6 +11,7 @@ import (
"bytes"
"encoding/hex"
"fmt"
"github.com/gogf/gf/v2/encoding/gbase64"
"github.com/gogf/gf/v2/encoding/gcompress"
"github.com/gogf/gf/v2/os/gfile"

View File

@ -9,14 +9,15 @@ package gres
import (
"archive/zip"
"context"
"github.com/gogf/gf/v2/internal/fileinfo"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/text/gregex"
"io"
"os"
"strings"
"time"
"github.com/gogf/gf/v2/internal/fileinfo"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/text/gregex"
)
// ZipPathWriter compresses `paths` to `writer` using zip compressing algorithm.

View File

@ -11,7 +11,7 @@ import (
"os"
)
// Close implements Close interface of http.File.
// Close implements interface of http.File.
func (f *File) Close() error {
return nil
}

View File

@ -9,7 +9,7 @@ package gres
import "github.com/gogf/gf/v2/container/gmap"
const (
// Default group name for instance usage.
// DefaultName Default group name for instance usage.
DefaultName = "default"
)

View File

@ -9,15 +9,14 @@ package gres
import (
"context"
"fmt"
"github.com/gogf/gf/v2/internal/intlog"
"os"
"path/filepath"
"strings"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/container/gtree"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/os/gtime"
)
type Resource struct {

View File

@ -7,14 +7,13 @@
package gres_test
import (
"github.com/gogf/gf/v2/os/gtime"
"strings"
"testing"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/debug/gdebug"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/os/gres"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
)

View File

@ -7,14 +7,12 @@
package gres_test
import (
_ "github.com/gogf/gf/v2/os/gres/testdata/data"
"testing"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/test/gtest"
"github.com/gogf/gf/v2/os/gres"
_ "github.com/gogf/gf/v2/os/gres/testdata/data"
"github.com/gogf/gf/v2/test/gtest"
)
func Test_Basic(t *testing.T) {

View File

@ -9,11 +9,11 @@ package grpool
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/container/glist"
"github.com/gogf/gf/v2/container/gtype"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
)
// Func is the pool function which contains context parameter.

View File

@ -8,10 +8,10 @@ package gsession
import (
"context"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/internal/intlog"
"time"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/os/gcache"
)

View File

@ -8,13 +8,13 @@ package gsession
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
"time"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
)
// Session struct for storing single session data, which is bound to a single request.

View File

@ -8,8 +8,9 @@ package gsession
import (
"context"
"github.com/gogf/gf/v2/container/gmap"
"time"
"github.com/gogf/gf/v2/container/gmap"
)
// Storage is the interface definition for session storage.

View File

@ -8,24 +8,20 @@ package gsession
import (
"context"
"os"
"time"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/container/gset"
"github.com/gogf/gf/v2/crypto/gaes"
"github.com/gogf/gf/v2/encoding/gbinary"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/internal/json"
"os"
"time"
"github.com/gogf/gf/v2/crypto/gaes"
"github.com/gogf/gf/v2/os/gtimer"
"github.com/gogf/gf/v2/container/gset"
"github.com/gogf/gf/v2/encoding/gbinary"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/os/gtimer"
)
// StorageFile implements the Session Storage interface with file system.

View File

@ -8,8 +8,9 @@ package gsession
import (
"context"
"github.com/gogf/gf/v2/container/gmap"
"time"
"github.com/gogf/gf/v2/container/gmap"
)
// StorageMemory implements the Session Storage interface with memory.

View File

@ -8,12 +8,12 @@ package gsession
import (
"context"
"time"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/database/gredis"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/internal/json"
"time"
"github.com/gogf/gf/v2/os/gtimer"
)

View File

@ -8,11 +8,11 @@ package gsession_test
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gsession"
"testing"
"time"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gsession"
"github.com/gogf/gf/v2/test/gtest"
)

View File

@ -8,11 +8,11 @@ package gsession_test
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gsession"
"testing"
"time"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gsession"
"github.com/gogf/gf/v2/test/gtest"
)

View File

@ -8,12 +8,12 @@ package gsession_test
import (
"context"
"github.com/gogf/gf/v2/database/gredis"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gsession"
"testing"
"time"
"github.com/gogf/gf/v2/database/gredis"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gsession"
"github.com/gogf/gf/v2/test/gtest"
)

View File

@ -8,12 +8,12 @@ package gsession_test
import (
"context"
"github.com/gogf/gf/v2/database/gredis"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gsession"
"testing"
"time"
"github.com/gogf/gf/v2/database/gredis"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gsession"
"github.com/gogf/gf/v2/test/gtest"
)

View File

@ -13,15 +13,15 @@ package gspath
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
"os"
"sort"
"strings"
"github.com/gogf/gf/v2/container/garray"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/text/gstr"
)
@ -53,7 +53,7 @@ func New(path string, cache bool) *SPath {
}
if len(path) > 0 {
if _, err := sp.Add(path); err != nil {
//intlog.Print(err)
// intlog.Print(err)
}
}
return sp
@ -143,7 +143,7 @@ func (sp *SPath) Add(path string) (realPath string, err error) {
}
// The added path must be a directory.
if gfile.IsDir(realPath) {
//fmt.Println("gspath:", realPath, sp.paths.Search(realPath))
// fmt.Println("gspath:", realPath, sp.paths.Search(realPath))
// It will not add twice for the same directory.
if sp.paths.Search(realPath) < 0 {
realPath = strings.TrimRight(realPath, gfile.Separator)

View File

@ -11,15 +11,15 @@ package gtime
import (
"fmt"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/utils"
"os"
"regexp"
"strconv"
"strings"
"time"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/internal/utils"
"github.com/gogf/gf/v2/text/gregex"
)
@ -231,19 +231,19 @@ func StrToTime(str string, format ...string) (*Time, error) {
local = time.Local
)
if match = timeRegex1.FindStringSubmatch(str); len(match) > 0 && match[1] != "" {
//for k, v := range match {
// for k, v := range match {
// match[k] = strings.TrimSpace(v)
//}
// }
year, month, day = parseDateStr(match[1])
} else if match = timeRegex2.FindStringSubmatch(str); len(match) > 0 && match[1] != "" {
//for k, v := range match {
// for k, v := range match {
// match[k] = strings.TrimSpace(v)
//}
// }
year, month, day = parseDateStr(match[1])
} else if match = timeRegex3.FindStringSubmatch(str); len(match) > 0 && match[1] != "" {
//for k, v := range match {
// for k, v := range match {
// match[k] = strings.TrimSpace(v)
//}
// }
s := strings.Replace(match[2], ":", "", -1)
if len(s) < 6 {
s += strings.Repeat("0", 6-len(s))

View File

@ -8,10 +8,11 @@ package gtime
import (
"bytes"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"strconv"
"time"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
)
// Time is a wrapper for time.Time for additional features.

View File

@ -7,10 +7,10 @@
package gtime_test
import (
"github.com/gogf/gf/v2/frame/g"
"testing"
"time"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
)
@ -18,7 +18,7 @@ import (
func Test_SetTimeZone(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
t.Assert(gtime.SetTimeZone("Asia/Shanghai"), nil)
//t.Assert(time.Local.String(), "Asia/Shanghai")
// t.Assert(time.Local.String(), "Asia/Shanghai")
})
}
@ -174,7 +174,7 @@ func Test_StrToTime(t *testing.T) {
}
}
//test err
// test err
_, err := gtime.StrToTime("2006-01-02 15:04:05", "aabbccdd")
if err == nil {
t.Error("test fail")
@ -184,44 +184,44 @@ func Test_StrToTime(t *testing.T) {
func Test_ConvertZone(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
//现行时间
// 现行时间
nowUTC := time.Now().UTC()
testZone := "America/Los_Angeles"
//转换为洛杉矶时间
// 转换为洛杉矶时间
t1, err := gtime.ConvertZone(nowUTC.Format("2006-01-02 15:04:05"), testZone, "")
if err != nil {
t.Error("test fail")
}
//使用洛杉矶时区解析上面转换后的时间
// 使用洛杉矶时区解析上面转换后的时间
laStr := t1.Time.Format("2006-01-02 15:04:05")
loc, err := time.LoadLocation(testZone)
t2, err := time.ParseInLocation("2006-01-02 15:04:05", laStr, loc)
//判断是否与现行时间匹配
// 判断是否与现行时间匹配
t.Assert(t2.UTC().Unix(), nowUTC.Unix())
})
//test err
// test err
gtest.C(t, func(t *gtest.T) {
//现行时间
// 现行时间
nowUTC := time.Now().UTC()
//t.Log(nowUTC.Unix())
// t.Log(nowUTC.Unix())
testZone := "errZone"
//错误时间输入
// 错误时间输入
_, err := gtime.ConvertZone(nowUTC.Format("06..02 15:04:05"), testZone, "")
if err == nil {
t.Error("test fail")
}
//错误时区输入
// 错误时区输入
_, err = gtime.ConvertZone(nowUTC.Format("2006-01-02 15:04:05"), testZone, "")
if err == nil {
t.Error("test fail")
}
//错误时区输入
// 错误时区输入
_, err = gtime.ConvertZone(nowUTC.Format("2006-01-02 15:04:05"), testZone, testZone)
if err == nil {
t.Error("test fail")
@ -269,7 +269,7 @@ func Test_ParseTimeFromContent(t *testing.T) {
timeTemp2 := gtime.ParseTimeFromContent("我是中文02.jan.2006 15:04:05我也是中文")
t.Assert(timeTemp2.Time.Format("2006-01-02 15:04:05"), "2006-01-02 15:04:05")
//test err
// test err
timeTempErr := gtime.ParseTimeFromContent("我是中文", "Y-m-d H:i:s")
if timeTempErr != nil {
t.Error("test fail")

View File

@ -7,10 +7,11 @@
package gtime_test
import (
"testing"
"github.com/gogf/gf/v2/internal/json"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
"testing"
)
func Test_Json_Pointer(t *testing.T) {

View File

@ -1,23 +1,24 @@
package gtime_test
import (
"testing"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
"testing"
)
func TestTime_Scan(t1 *testing.T) {
gtest.C(t1, func(t *gtest.T) {
tt := gtime.Time{}
//test string
// test string
s := gtime.Now().String()
t.Assert(tt.Scan(s), nil)
t.Assert(tt.String(), s)
//test nano
// test nano
n := gtime.TimestampNano()
t.Assert(tt.Scan(n), nil)
t.Assert(tt.TimestampNano(), n)
//test nil
// test nil
none := (*gtime.Time)(nil)
t.Assert(none.Scan(nil), nil)
t.Assert(none, nil)
@ -31,7 +32,7 @@ func TestTime_Value(t1 *testing.T) {
s, err := tt.Value()
t.Assert(err, nil)
t.Assert(s, tt.Time)
//test nil
// test nil
none := (*gtime.Time)(nil)
s, err = none.Value()
t.Assert(err, nil)

View File

@ -20,10 +20,10 @@ package gtimer
import (
"context"
"github.com/gogf/gf/v2/container/gtype"
"sync"
"time"
"github.com/gogf/gf/v2/container/gtype"
"github.com/gogf/gf/v2/os/gcmd"
)

View File

@ -8,6 +8,7 @@ package gtimer
import (
"context"
"github.com/gogf/gf/v2/container/gtype"
)

View File

@ -8,9 +8,10 @@ package gtimer
import (
"container/heap"
"github.com/gogf/gf/v2/container/gtype"
"math"
"sync"
"github.com/gogf/gf/v2/container/gtype"
)
// priorityQueue is an abstract data type similar to a regular queue or stack data structure in which

View File

@ -8,8 +8,9 @@ package gtimer
import (
"context"
"github.com/gogf/gf/v2/container/gtype"
"time"
"github.com/gogf/gf/v2/container/gtype"
)
func New(options ...TimerOptions) *Timer {

View File

@ -8,10 +8,11 @@ package gtimer
import (
"context"
"github.com/gogf/gf/v2/container/garray"
"github.com/gogf/gf/v2/test/gtest"
"testing"
"time"
"github.com/gogf/gf/v2/container/garray"
"github.com/gogf/gf/v2/test/gtest"
)
func TestTimer_Proceed(t *testing.T) {

View File

@ -12,11 +12,11 @@ package gview
import (
"context"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2"
"github.com/gogf/gf/v2/container/garray"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/os/gcmd"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/os/glog"

View File

@ -9,17 +9,16 @@ package gview
import (
"context"
"fmt"
"github.com/gogf/gf/v2/internal/json"
"github.com/gogf/gf/v2/util/gutil"
htmltpl "html/template"
"strings"
"github.com/gogf/gf/v2/encoding/ghtml"
"github.com/gogf/gf/v2/encoding/gurl"
"github.com/gogf/gf/v2/internal/json"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
htmltpl "html/template"
"github.com/gogf/gf/v2/util/gutil"
)
// buildInFuncDump implements build-in template function: dump

View File

@ -8,6 +8,7 @@ package gview
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/i18n/gi18n"
@ -146,7 +147,7 @@ func (view *View) SetPath(path string) error {
view.paths.Clear()
view.paths.Append(realPath)
view.fileCacheMap.Clear()
//glog.Debug("[gview] SetPath:", realPath)
// glog.Debug("[gview] SetPath:", realPath)
return nil
}

View File

@ -8,6 +8,7 @@ package gview
import (
"context"
"github.com/gogf/gf/v2/i18n/gi18n"
"github.com/gogf/gf/v2/util/gconv"
)

View File

@ -9,7 +9,7 @@ package gview
import "github.com/gogf/gf/v2/container/gmap"
const (
// Default group name for instance usage.
// DefaultName Default group name for instance usage.
DefaultName = "default"
)

View File

@ -10,6 +10,11 @@ import (
"bytes"
"context"
"fmt"
htmltpl "html/template"
"strconv"
"strings"
texttpl "text/template"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/encoding/ghash"
"github.com/gogf/gf/v2/errors/gcode"
@ -23,10 +28,6 @@ import (
"github.com/gogf/gf/v2/os/gspath"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gutil"
htmltpl "html/template"
"strconv"
"strings"
texttpl "text/template"
)
const (

View File

@ -8,21 +8,21 @@ package gview_test
import (
"context"
"github.com/gogf/gf/v2/encoding/ghtml"
"github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/util/gconv"
"io/ioutil"
"os"
"strings"
"testing"
"time"
"github.com/gogf/gf/v2/encoding/ghtml"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/os/gview"
"github.com/gogf/gf/v2/test/gtest"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
)
func init() {
@ -45,13 +45,13 @@ func Test_Basic(t *testing.T) {
t.Assert(err != nil, false)
t.Assert(result, "hello gf,version:1.7.0;hello gf,version:1.7.0;that's all")
//测试api方法
// 测试api方法
str = `hello {{.name}}`
result, err = gview.ParseContent(context.TODO(), str, g.Map{"name": "gf"})
t.Assert(err != nil, false)
t.Assert(result, "hello gf")
//测试instance方法
// 测试instance方法
result, err = gview.Instance().ParseContent(context.TODO(), str, g.Map{"name": "gf"})
t.Assert(err != nil, false)
t.Assert(result, "hello gf")
@ -224,7 +224,7 @@ func Test_FuncInclude(t *testing.T) {
templatePath := gfile.Pwd() + gfile.Separator + "template"
gfile.Mkdir(templatePath)
defer gfile.Remove(templatePath)
//headerFile, _ := gfile.Create(templatePath + gfile.Separator + "header.html")
// headerFile, _ := gfile.Create(templatePath + gfile.Separator + "header.html")
err := ioutil.WriteFile(templatePath+gfile.Separator+"header.html", []byte(header), 0644)
if err != nil {
t.Error(err)

View File

@ -8,11 +8,12 @@ package gview_test
import (
"context"
"testing"
"github.com/gogf/gf/v2/debug/gdebug"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gview"
"github.com/gogf/gf/v2/test/gtest"
"testing"
)
func Test_Config(t *testing.T) {

View File

@ -8,12 +8,13 @@ package gview_test
import (
"context"
"testing"
"github.com/gogf/gf/v2/debug/gdebug"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/os/gview"
"github.com/gogf/gf/v2/test/gtest"
"testing"
)
func Test_Encode_Parse(t *testing.T) {

View File

@ -11,9 +11,8 @@ import (
"testing"
"github.com/gogf/gf/v2/debug/gdebug"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/test/gtest"
)