.
This commit is contained in:
parent
fd077efa19
commit
4af0d31c69
@ -210,29 +210,33 @@ type ChanIO struct {
|
||||
}
|
||||
|
||||
func (c *ChanIO) Write(p []byte) (int, error) {
|
||||
for i := range len(p) {
|
||||
c.ch <- p[i]
|
||||
for _, b := range p {
|
||||
c.ch <- b
|
||||
}
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
// read at least 1 byte, but don't block if nothing in channel
|
||||
func (c *ChanIO) Read(p []byte) (int, error) {
|
||||
data, ok := <-c.ch
|
||||
for i := 0; i < cap(p); i++ {
|
||||
data, ok = <-c.ch
|
||||
// read at least 1 byte, but don't block if nothing more in channel
|
||||
func (c *ChanIO) Read(data []byte) (int, error) {
|
||||
var ok bool
|
||||
var idx int
|
||||
|
||||
data[idx], ok = <-c.ch
|
||||
if !ok {
|
||||
return 0, io.EOF
|
||||
}
|
||||
idx++
|
||||
|
||||
for len(c.ch) > 0 && idx < len(data) {
|
||||
data[idx], ok = <- c.ch
|
||||
if !ok {
|
||||
return len(p), io.EOF
|
||||
return idx, io.EOF
|
||||
}
|
||||
|
||||
p[i] = data
|
||||
if len(c.ch) < 1 {
|
||||
break
|
||||
}
|
||||
idx++
|
||||
}
|
||||
|
||||
return len(p), nil
|
||||
return idx, nil
|
||||
}
|
||||
|
||||
type gitMsg struct {
|
||||
|
@ -219,3 +219,11 @@ Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>` + "\x00"
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/*func TestCommitTreeParsingOfHead(t *testing.T) {
|
||||
t.Run("reads HEAD and parses the tree", func (t *testing.T) {
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user