2017-11-23 10:21:28 +08:00
|
|
|
package main
|
2019-07-20 16:41:17 +08:00
|
|
|
|
2020-01-08 20:00:42 +08:00
|
|
|
import (
|
2020-01-20 19:56:42 +08:00
|
|
|
"fmt"
|
2020-01-16 21:04:28 +08:00
|
|
|
"github.com/gogf/gf/frame/g"
|
2020-01-20 19:56:42 +08:00
|
|
|
"github.com/gogf/gf/util/gconv"
|
2020-01-08 20:00:42 +08:00
|
|
|
)
|
2019-08-07 16:58:01 +08:00
|
|
|
|
2020-01-20 19:56:42 +08:00
|
|
|
type TokenRequest struct {
|
|
|
|
Scope string
|
|
|
|
Watermark bool
|
|
|
|
Policy *g.Var
|
|
|
|
}
|
|
|
|
|
2019-08-08 22:58:49 +08:00
|
|
|
func main() {
|
2020-01-20 20:18:24 +08:00
|
|
|
s := "123456"
|
|
|
|
fmt.Println(s[0:2])
|
|
|
|
fmt.Println(s[1:3])
|
|
|
|
return
|
2020-01-20 19:56:42 +08:00
|
|
|
// s := `
|
|
|
|
//{
|
|
|
|
// "policy": {"name":"john"},
|
|
|
|
// "scope": "pub-med-panel",
|
|
|
|
// "watermark": true
|
|
|
|
//}
|
|
|
|
//`
|
|
|
|
var t *TokenRequest
|
|
|
|
m := g.Map{
|
|
|
|
"policy": g.Map{"name": "john"},
|
|
|
|
"scope": "pub-med-panel",
|
|
|
|
"watermark": true,
|
|
|
|
}
|
|
|
|
err := gconv.Struct(m, &t)
|
|
|
|
fmt.Println(err)
|
|
|
|
fmt.Println(t.Policy)
|
2019-07-20 16:41:17 +08:00
|
|
|
}
|