一, 服務端
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
)
type User struct {
ID int `json:"id"` // 字段標籤指定 JSON 鍵名
Name string `json:"name"`
}
func handler4Tes
一, 服務器1
package main
import (
"log"
"net"
"net/http"
"net/rpc"
)
type RpcServer struct {
}
type RpcRequest struct {
NumO int
Num1 int
}
type RpcResponse struct {
Num int
}
一,情景
因為golang.org/x/net/websocket未被go團隊納入標準庫,go團隊也未推薦使用,且次庫還有一些問題,並且不再維護。
所以,推薦使用:github.com/gorilla/websocket
安裝命令:
go get github.com/gorilla/websocket@latest
二, 服務端
文檔地址:https://www.kancloud.cn/shuangdeyu/gin_book/949411
一,請求類型
GET / POST
package main
import (
"github.com/gin-gonic/gin"
"net/http"
)
func main() {
r := gin.Default()
r.