From 47b0221b8238ded368a2c291c1603f860e4e900e Mon Sep 17 00:00:00 2001 From: Rustem B Date: Tue, 16 Jul 2019 22:05:49 +0500 Subject: [PATCH] os: hostname function --- vlib/os/os.v | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vlib/os/os.v b/vlib/os/os.v index 507a444e78..49f69ee874 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -483,6 +483,14 @@ pub fn user_os() string { 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. pub fn home_dir() string { mut home := os.getenv('HOME')