os: hostname function

pull/1190/head
Rustem B 2019-07-16 22:05:49 +05:00 committed by Alexander Medvednikov
parent 36442976c3
commit 47b0221b82
1 changed files with 8 additions and 0 deletions

View File

@ -483,6 +483,14 @@ pub fn user_os() string {
return 'unknown' return 'unknown'
} }
// hostname returns hostname
pub fn hostname() string {
mut hname := [1024]byte
hname[1023] = `\0`
C.gethostname(&hname, 1023)
return tos_clone(hname)
}
// home_dir returns path to user's home directory. // home_dir returns path to user's home directory.
pub fn home_dir() string { pub fn home_dir() string {
mut home := os.getenv('HOME') mut home := os.getenv('HOME')