go test 可以執行單元測試 , 一般把所有go文件測試單元都執行一遍
現在如果想要執行某一個指定的測試函數 , 可以像這樣
go test -v -run 測試函數名字
例如:
rpc_test.go
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") }
執行 TestClientRpc函數
go test -v -run TestClientRpc