From 251e32948e9e7197b29e82ef37d62331910854e3 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 17 Jul 2019 13:50:58 +0200 Subject: [PATCH] fix Windows build: move hostname to net/ --- vlib/net/net.v | 13 +++++++++++++ vlib/os/os.v | 11 ----------- 2 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 vlib/net/net.v diff --git a/vlib/net/net.v b/vlib/net/net.v new file mode 100644 index 0000000000..387a1c21ff --- /dev/null +++ b/vlib/net/net.v @@ -0,0 +1,13 @@ +module net + +// hostname returns the host name reported by the kernel. +pub fn hostname() ?string { + mut name := [256]byte + // https://www.ietf.org/rfc/rfc1035.txt + // The host name is returned as a null-terminated string. + res := C.gethostname(&name, 256) + if res != 0 { + return error('os.hostname() cannot get the host name') + } + return tos_clone(name) +} diff --git a/vlib/os/os.v b/vlib/os/os.v index 3fdf5bf1c9..2056d45a89 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -484,17 +484,6 @@ pub fn user_os() string { } -// hostname returns the host name reported by the kernel. -pub fn hostname() ?string { - mut name := [256]byte - // https://www.ietf.org/rfc/rfc1035.txt - // The host name is returned as a null-terminated string. - res := C.gethostname(&name, 256) - if res != 0 { - return error('os.hostname() cannot get the host name') - } - return tos_clone(name) -} // home_dir returns path to user's home directory. pub fn home_dir() string {