我連接到使用類似於Go代碼一個TCP/IP服務器獲取一個io.ByteReader:轉到:從net.Conn
conn, err := net.Dial("tcp", host+":"+strconv.Itoa(port))
現在我需要使用binary.ReadVariant這需要一個io.ByteReader,所以嘗試寫這樣的代碼:
var length int64
var err error
length, err = binary.ReadVarint(conn)
讓我像一個錯誤:
./main.go:67: cannot use conn (type net.Conn) as type io.ByteReader in function argument:
net.Conn does not implement io.ByteReader (missing ReadByte method)
我怎樣才能使這項工作?