Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 4 of 4 for ReadByte (0.26 sec)

  1. src/bytes/buffer_test.go

    		buf.WriteByte(testString[1])
    		c, err := buf.ReadByte()
    		if want := testString[1]; err != nil || c != want {
    			t.Errorf("ReadByte: got (%q, %v), want (%q, %v)", c, err, want, nil)
    		}
    		c, err = buf.ReadByte()
    		if err != io.EOF {
    			t.Errorf("ReadByte: got (%q, %v), want (%q, %v)", c, err, byte(0), io.EOF)
    		}
    	}
    }
    
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Fri Apr 26 13:31:36 GMT 2024
    - 18.6K bytes
    - Viewed (0)
  2. src/bytes/buffer.go

    		n = m
    	}
    	data := b.buf[b.off : b.off+n]
    	b.off += n
    	if n > 0 {
    		b.lastRead = opRead
    	}
    	return data
    }
    
    // ReadByte reads and returns the next byte from the buffer.
    // If no byte is available, it returns error io.EOF.
    func (b *Buffer) ReadByte() (byte, error) {
    	if b.empty() {
    		// Buffer is empty, reset to recover space.
    		b.Reset()
    		return 0, io.EOF
    	}
    	c := b.buf[b.off]
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Fri Oct 13 17:10:31 GMT 2023
    - 15.7K bytes
    - Viewed (0)
  3. src/bytes/example_test.go

    	}
    	fmt.Println(n)
    	fmt.Println(b.String())
    	fmt.Println(string(rdbuf))
    	// Output:
    	// 1
    	// bcde
    	// a
    }
    
    func ExampleBuffer_ReadByte() {
    	var b bytes.Buffer
    	b.Grow(64)
    	b.Write([]byte("abcde"))
    	c, err := b.ReadByte()
    	if err != nil {
    		panic(err)
    	}
    	fmt.Println(c)
    	fmt.Println(b.String())
    	// Output:
    	// 97
    	// bcde
    }
    
    func ExampleClone() {
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Mon Mar 04 15:54:40 GMT 2024
    - 15K bytes
    - Viewed (1)
  4. src/bufio/bufio.go

    	n = copy(p, b.buf[b.r:b.w])
    	b.r += n
    	b.lastByte = int(b.buf[b.r-1])
    	b.lastRuneSize = -1
    	return n, nil
    }
    
    // ReadByte reads and returns a single byte.
    // If no byte is available, returns an error.
    func (b *Reader) ReadByte() (byte, error) {
    	b.lastRuneSize = -1
    	for b.r == b.w {
    		if b.err != nil {
    			return 0, b.readErr()
    		}
    		b.fill() // buffer is empty
    	}
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Thu Oct 12 14:39:08 GMT 2023
    - 21.8K bytes
    - Viewed (0)
Back to top