-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.go
64 lines (53 loc) · 1.12 KB
/
test.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
62
63
64
package main
import (
"fmt"
"reflect"
"regexp"
"os"
"bytes"
)
type A struct {
b int
}
func main() {
matched, err := regexp.MatchString("foo.*", "seafood")
fmt.Println(matched, err)
matched, err = regexp.MatchString("bar.*", "seafood")
fmt.Println(matched, err)
matched, err = regexp.MatchString(`a(b`, "seafood")
fmt.Println(matched, err)
matched, err = regexp.MatchString(`/(css|js)/[a-z]+\.css`, "/css/fdfd.css")
matched, err = regexp.MatchString(`/(css|js)/[a-z]+\.(css|js)`, "/js/fdfd.js")
fmt.Println(matched, err)
fmt.Println(reflect.TypeOf(matched))
var a []A = []A{{1},{2},{3}}
for _, aa := range a {
print(aa.b)
}
w := &A{}
fmt.Println(w)
file := "./db"
f, err := os.OpenFile(file, os.O_RDWR|os.O_CREATE, 0); if err != nil { fmt.Println(err) }
defer f.Close()
b := make([]byte, 2, 4)
f.Read(b)
fmt.Println(string(b))
sss := S{1}
fmt.Println("sss", sss.hh())
b2 := make([]byte, 30)
b2[4] = 3
b2[5] = 4
fmt.Println(b2[4:6])
if bytes.Equal(b2[4:6], []byte{3,4}) {
fmt.Println("ok")
}
if b2[4] == 3 {
fmt.Println("okkk")
}
}
type S struct {
k int
}
func (s *S) hh() int {
return s.k
}