Function hasEnvVarConstant [src]

On Windows, key must be valid UTF-8.

Prototype

pub fn hasEnvVarConstant(comptime key: []const u8) bool

Parameters

key: []const u8

Example

test hasEnvVarConstant { if (native_os == .wasi and !builtin.link_libc) return error.SkipZigTest; try testing.expect(!hasEnvVarConstant("BADENV")); }

Source

pub fn hasEnvVarConstant(comptime key: []const u8) bool { if (native_os == .windows) { const key_w = comptime unicode.utf8ToUtf16LeStringLiteral(key); return getenvW(key_w) != null; } else if (native_os == .wasi and !builtin.link_libc) { @compileError("hasEnvVarConstant is not supported for WASI without libc"); } else { return posix.getenv(key) != null; } }