comment update

This commit is contained in:
John
2019-11-01 20:36:09 +08:00
parent 82bf21e831
commit dcb74ee9df
4 changed files with 40 additions and 28 deletions

View File

@ -0,0 +1,21 @@
package main
import (
"fmt"
"github.com/gogf/gf/frame/g"
)
func main() {
content := `{{.name}} says "a{#hello}{#world}!"`
result1, _ := g.View().ParseContent(content, g.Map{
"name": "john",
"I18nLanguage": "zh-CN",
})
fmt.Println(result1)
result2, _ := g.View().ParseContent(content, g.Map{
"name": "john",
"I18nLanguage": "ja",
})
fmt.Println(result2)
}

View File

@ -1,35 +1,22 @@
package main
import (
"fmt"
"github.com/gogf/gf/encoding/gbase64"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/net/gipv4"
"github.com/gogf/gf/os/gproc"
"github.com/gogf/gf/os/gtime"
"math"
"net"
"github.com/gogf/gf/net/ghttp"
)
func main() {
netInterfaces, err := net.Interfaces()
if err != nil {
fmt.Printf("fail to get net interfaces: %v", err)
}
s := g.Server()
s.BindHandler("/", func(r *ghttp.Request) {
for _, netInterface := range netInterfaces {
macAddr := netInterface.HardwareAddr.String()
if len(macAddr) == 0 {
continue
}
fmt.Println(net.ParseMAC(netInterface.HardwareAddr.String()))
}
})
s.BindHandler("/user", func(r *ghttp.Request) {
return
ip, _ := gipv4.IntranetIP()
g.Dump(math.MaxInt64)
g.Dump(gipv4.Ip2long(ip), gbase64.EncodeString(ip))
g.Dump(gproc.Pid())
g.Dump(gtime.Nanosecond())
})
s.BindHandler("/user/:id", func(r *ghttp.Request) {
r.Response.Write(r.GetRouterString("id"))
})
s.EnablePprof()
s.SetPort(3000)
s.Run()
}