https://segmentfault.com/a/ package main import ( "bufio" "code.google.com/p/mahonia" "fmt" "io" "net" "os" ) func main() { fmt.Println("create a server or client?") reader := bufio.NewReader(os.Stdin) input, _, _ := reader.ReadLine() if string(input) == "server" { Server() } if string(input) == "client" { Client() } else { fmt.Println(Show("err arguments,entering again!.\r\n alternaltive argument is server or client")) os.Exit(0) } } func Show(s string) string { enc := mahonia.NewEncoder("gbk") //中文转码
通过拆分多帧的方式WebSocket发送图片
https://segmentfault.com/a/ package main import ( "fmt" "golang.org/x/net/websocket" "log" "net/http" "os" "time" ) var ( dirPath string test byte lenFile int ) func check(e error) { if e != nil { panic(e) } } func ChatServer(ws *websocket.Conn) { defer ws.Close() var test []byte var payload []byte for { err := websocket.Message.Receive(ws, &payload) if err != nil { log.Println(err) } fmt.Println("Payload: ", len(payload)) test = append(test, payload...) fmt.Println("Test: ", len(test)) fo, err := os.
Go学习【三】一个简单的orm
https://segmentfault.com/a/ 碎语:(请自行跳过) 距离上篇文章发布也有半个月的时间了 然后这半个月 也没有用go写项目或继续学习 只能算简单的入门了 以后如果有需要的话 或许会深