Revert "add `unsetenv`, `setenv`, `clearenv` to os module (#583)"
This reverts commit 6cb5eee1b2
.
pull/528/head^2
parent
7ca00c8f5e
commit
cc1ecd1996
18
os/os.v
18
os/os.v
|
@ -316,24 +316,6 @@ pub fn getenv(key string) string {
|
|||
return tos2(s)
|
||||
}
|
||||
|
||||
|
||||
pub fn setenv(name string, value string, overwrite bool) int {
|
||||
return C.setenv(name.cstr(), value.cstr(), overwrite)
|
||||
}
|
||||
|
||||
pub fn unsetenv(name string) int {
|
||||
return C.unsetenv(name.cstr())
|
||||
}
|
||||
|
||||
pub fn clearenv() {
|
||||
C.clearenv()
|
||||
}
|
||||
|
||||
fn exit(code int) {
|
||||
C.exit(code)
|
||||
}
|
||||
|
||||
|
||||
// `file_exists` returns true if `path` exists.
|
||||
pub fn file_exists(path string) bool {
|
||||
res := false
|
||||
|
|
26
os/os_test.v
26
os/os_test.v
|
@ -1,26 +0,0 @@
|
|||
import os
|
||||
|
||||
fn test_setenv() {
|
||||
os.setenv('foo', 'bar', true)
|
||||
assert os.getenv('foo') == 'bar'
|
||||
|
||||
// `setenv` should not set if `overwrite` is false
|
||||
os.setenv('foo', 'bar2', false)
|
||||
assert os.getenv('foo') == 'bar'
|
||||
|
||||
// `setenv` should overwrite if `overwrite` is true
|
||||
os.setenv('foo', 'bar2', true)
|
||||
assert os.getenv('foo') == 'bar2'
|
||||
}
|
||||
|
||||
fn test_unsetenv() {
|
||||
os.setenv('foo', 'bar', true)
|
||||
os.unsetenv('foo')
|
||||
assert os.getenv('foo') == ''
|
||||
}
|
||||
|
||||
fn test_clearenv() {
|
||||
os.setenv('foo', 'bar', true)
|
||||
os.clearenv()
|
||||
assert os.getenv('foo') == ''
|
||||
}
|
Loading…
Reference in New Issue