github.com/nyan233/littlerpc@v0.4.6-0.20230316182519-0c8d5c48abaf/core/utils/utils.go (about) 1 package utils 2 3 func ReadFromData(maxRead int, data []byte) (int, []byte) { 4 if data == nil { 5 return -1, nil 6 } 7 if len(data) < maxRead { 8 return len(data), data 9 } else { 10 return maxRead, data[:maxRead] 11 } 12 }