mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
add example for package gres
This commit is contained in:
@ -1,16 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/os/gres"
|
||||
_ "github.com/gogf/gf/os/gres/testdata"
|
||||
)
|
||||
|
||||
func main() {
|
||||
gres.Dump()
|
||||
//file := gres.Get("www")
|
||||
//fmt.Println(file.Open())
|
||||
//g.Dump(gres.ScanDir("/root/image", "*"))
|
||||
//g.Dump(gres.Scan("/root/image/", "*", true))
|
||||
//g.Dump(gres.Scan("/template", "*"))
|
||||
//g.Dump(gres.Scan("/template/layout2", "*.html", true))
|
||||
}
|
||||
19
.example/os/gres/gres_example.go
Normal file
19
.example/os/gres/gres_example.go
Normal file
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/net/ghttp"
|
||||
_ "github.com/gogf/gf/os/gres/testdata/example/boot"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := g.Server()
|
||||
s.Group("/", func(group *ghttp.RouterGroup) {
|
||||
group.GET("/template", func(r *ghttp.Request) {
|
||||
r.Response.WriteTplDefault(g.Map{
|
||||
"name": "GoFrame",
|
||||
})
|
||||
})
|
||||
})
|
||||
s.Run()
|
||||
}
|
||||
@ -1,31 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/frame/gins"
|
||||
"github.com/gogf/gf/os/glog"
|
||||
"github.com/gogf/gf/crypto/gaes"
|
||||
"github.com/gogf/gf/os/gfile"
|
||||
"github.com/gogf/gf/os/gres"
|
||||
)
|
||||
|
||||
func getNameLogger(name, path string) *glog.Logger {
|
||||
inst := gins.Get(name)
|
||||
if inst == nil {
|
||||
logger := g.Log(name)
|
||||
logConf := map[string]interface{}{
|
||||
"Path": path,
|
||||
"Level": "ALL",
|
||||
}
|
||||
if err := logger.SetConfigWithMap(logConf); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return logger
|
||||
}
|
||||
return inst.(*glog.Logger)
|
||||
}
|
||||
var (
|
||||
CryptoKey = []byte("x76cgqt36i9c863bzmotuf8626dxiwu0")
|
||||
)
|
||||
|
||||
func main() {
|
||||
alog := getNameLogger("logger.日志1", "c:/logger1")
|
||||
alog.Print(1)
|
||||
|
||||
blog := getNameLogger("logger.日志2", "c:/logger2")
|
||||
blog.Print(2)
|
||||
binContent, err := gres.Pack("public,config")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
binContent, err = gaes.Encrypt(binContent, CryptoKey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := gfile.PutBytes("data.bin", binContent); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user