1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: replace []byte with []u8

This commit is contained in:
Alexander Medvednikov
2022-04-15 15:35:35 +03:00
parent 0527ac633e
commit fb192d949b
164 changed files with 533 additions and 533 deletions

View File

@ -199,7 +199,7 @@ pub fn (mut c StreamConn) write_ptr(b &byte, len int) ?int {
}
// write blocks and attempts to write all data
pub fn (mut c StreamConn) write(bytes []byte) ?int {
pub fn (mut c StreamConn) write(bytes []u8) ?int {
return c.write_ptr(bytes.data, bytes.len)
}
@ -230,7 +230,7 @@ pub fn (mut c StreamConn) read_ptr(buf_ptr &byte, len int) ?int {
return net.socket_error(code)
}
pub fn (mut c StreamConn) read(mut buf []byte) ?int {
pub fn (mut c StreamConn) read(mut buf []u8) ?int {
return c.read_ptr(buf.data, buf.len)
}

View File

@ -5,7 +5,7 @@ const test_port = os.join_path(os.temp_dir(), 'unix_domain_socket')
fn handle_conn(mut c unix.StreamConn) {
for {
mut buf := []byte{len: 100, init: 0}
mut buf := []u8{len: 100, init: 0}
read := c.read(mut buf) or {
println('Server: connection dropped')
return
@ -31,7 +31,7 @@ fn echo() ? {
}
data := 'Hello from vlib/net!'
c.write_string(data) ?
mut buf := []byte{len: 4096}
mut buf := []u8{len: 4096}
read := c.read(mut buf) ?
assert read == data.len
for i := 0; i < read; i++ {

View File

@ -21,7 +21,7 @@ fn test_that_net_and_net_unix_can_be_imported_together_without_conflicts() ? {
//
data := 'Hello from vlib/net!'
c.write_string(data) ?
mut buf := []byte{len: 100}
mut buf := []u8{len: 100}
assert c.read(mut buf) ? == data.len
eprintln('< client read back buf: |${buf[0..data.len].bytestr()}|')
assert buf[0..data.len] == data.bytes()
@ -33,7 +33,7 @@ fn perror(s string) ? {
fn handle_conn(mut c unix.StreamConn) ? {
for {
mut buf := []byte{len: 100, init: 0}
mut buf := []u8{len: 100, init: 0}
read := c.read(mut buf) or { return perror('Server: connection dropped') }
eprintln('> server read ${read:3}, buf: |$buf.bytestr()|')
c.write(buf[..read]) or { return perror('Server: connection dropped') }