mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
remove additional line from write_file
This commit is contained in:
parent
dc8c84a2a8
commit
1cd95091f2
@ -470,7 +470,7 @@ pub fn home_dir() string {
|
||||
// write_file writes text data to a file in `path`.
|
||||
pub fn write_file(path, text string) {
|
||||
f := os.create(path)
|
||||
f.writeln(text)
|
||||
f.write(text)
|
||||
f.close()
|
||||
}
|
||||
|
||||
|
@ -19,3 +19,15 @@ fn test_unsetenv() {
|
||||
assert os.getenv('foo') == ''
|
||||
}
|
||||
|
||||
fn test_write_and_read_string_to_file() {
|
||||
filename := './test1.txt'
|
||||
hello := 'hello world!'
|
||||
os.write_file(filename, hello)
|
||||
assert hello.len == os.file_size(filename)
|
||||
|
||||
read_hello := os.read_file(filename) or {
|
||||
panic('error reading file $filename')
|
||||
return
|
||||
}
|
||||
assert hello == read_hello
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user