parent
07b9a1ba9c
commit
d9bdfaf2ef
@ -0,0 +1,11 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"log"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetOutboundIP(t *testing.T) {
|
||||
ip, err := GetOutboundIP()
|
||||
log.Println(ip, err)
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package tools
|
||||
|
||||
import "fmt"
|
||||
|
||||
func MyTest() {
|
||||
type MConn struct {
|
||||
Name string
|
||||
}
|
||||
var conn *MConn
|
||||
var conn2 MConn
|
||||
conn3 := new(MConn)
|
||||
conn4 := &MConn{}
|
||||
fmt.Printf("%v,%v,%v,%v \r\n", conn, conn2, conn3, conn4)
|
||||
|
||||
var mMap map[string][]*MConn
|
||||
m1, _ := mMap["name"]
|
||||
//if ok {
|
||||
// m1.Name = "qqq"
|
||||
//}
|
||||
fmt.Printf("ssss%T", m1)
|
||||
}
|
||||
func MyStruct() {
|
||||
type s2 struct {
|
||||
name string
|
||||
}
|
||||
aa := s2{
|
||||
name: "aa",
|
||||
}
|
||||
bb := s2{
|
||||
name: "aa",
|
||||
}
|
||||
fmt.Printf("%v\n", aa == bb)
|
||||
|
||||
type s1 struct {
|
||||
one map[string]string
|
||||
two []string
|
||||
three string
|
||||
}
|
||||
|
||||
a := &s1{
|
||||
one: map[string]string{"aaa": "bbb"},
|
||||
two: []string{"aaa", "bbb"},
|
||||
three: "aaaa",
|
||||
}
|
||||
b := &s1{
|
||||
one: map[string]string{"aaa": "bbb"},
|
||||
two: []string{"aaa", "bbb"},
|
||||
three: "aaaa",
|
||||
}
|
||||
c := a
|
||||
fmt.Printf("%v;%v", a == b, a == c)
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMyTest(t *testing.T) {
|
||||
MyTest()
|
||||
}
|
||||
func TestMyStruct(t *testing.T) {
|
||||
MyStruct()
|
||||
}
|
||||
|
||||
type SMap struct {
|
||||
sync.RWMutex
|
||||
Map map[int]int
|
||||
}
|
||||
|
||||
func (l *SMap) readMap(key int) (int, bool) {
|
||||
l.RLock()
|
||||
value, ok := l.Map[key]
|
||||
l.RUnlock()
|
||||
return value, ok
|
||||
}
|
||||
|
||||
func (l *SMap) writeMap(key int, value int) {
|
||||
l.Lock()
|
||||
l.Map[key] = value
|
||||
l.Unlock()
|
||||
}
|
||||
|
||||
var mMap *SMap
|
||||
|
||||
func TestMyMap(t *testing.T) {
|
||||
mMap = &SMap{
|
||||
Map: make(map[int]int),
|
||||
}
|
||||
|
||||
for i := 0; i < 10000; i++ {
|
||||
go func() {
|
||||
mMap.writeMap(i, i)
|
||||
}()
|
||||
go readMap(i)
|
||||
}
|
||||
}
|
||||
func readMap(i int) (int, bool) {
|
||||
return mMap.readMap(i)
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"go-fly-muti/frpc"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestClientRpc(t *testing.T) {
|
||||
frpc.ClientRpc()
|
||||
}
|
||||
func TestServerRpc(t *testing.T) {
|
||||
frpc.NewRpcServer("127.0.0.1:8082")
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package tools
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSendSmtp(t *testing.T) {
|
||||
body := "<a href=''>hello</a>"
|
||||
SendSmtp("smtp.sina.cn:25", "taoshihan1@sina.com", "382e8a5e11cfae8c", []string{"taoshihan1@sina.com"}, "123456", body)
|
||||
}
|
@ -1,15 +1,5 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"mime"
|
||||
)
|
||||
func MyPointer() {
|
||||
|
||||
func main() {
|
||||
dec := new(mime.WordDecoder)
|
||||
header, err := dec.DecodeHeader("=?utf-8?q?=C3=89ric?= <eric@example.org>, =?utf-8?q?Ana=C3=AFs?= <anais@example.org>")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(header)
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
package tools
|
Loading…
Reference in new issue