-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mygo.go
61 lines (52 loc) · 1.01 KB
/
Mygo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"fmt"
"github.com/golang/glog"
"bufio"
"os"
"flag"
"reflect"
"time"
)
const (
file1 = "6.9MB.jpg"
file2 = "26MB.jpg"
file3 = "1MB.gif"
file4 = "3.7MB.tga"
file5 = "13.4MB.pdf"
)
var counterPool = make(map[string]time.Time)
const rootpath = "/home/dx/GoWorkBench/src/dx/taishan/data/comment_files"
const hextable = "0123456789abcdef"
func main() {
flag.Set("logtostderr", "true")
flag.Parse()
var none interface{}
name := "123 '123' \r dfdfd"
none = name
if v,ok:=none.(string);ok{
glog.Info(v)
}
}
func InputLoop() {
rd := bufio.NewReader(os.Stdin)
for {
str, err := rd.ReadString('\n')
if err != nil {
fmt.Println(err)
}
fmt.Println(str)
}
}
func reflect_example() {
method := func(i string) map[string]string {
fmt.Println(i)
return map[string]string{"id": "id1"}
}
var v reflect.Value
v = reflect.ValueOf(method)
vs := []reflect.Value{reflect.ValueOf("myStrings")}
rvs := v.Call(vs)
res := rvs[0].MapIndex(reflect.ValueOf("id")).String()
fmt.Println(res)
}