import{_ as l,o as p,c as o,k as s,a,X as n}from"./chunks/framework.6e839c56.js";const C=JSON.parse('{"title":"System","description":"","frontmatter":{},"headers":[],"relativePath":"en/api/packages/system.md","filePath":"en/api/packages/system.md"}'),e={name:"en/api/packages/system.md"},t=s("h1",{id:"System",tabindex:"-1"},[a("System "),s("a",{class:"header-anchor",href:"#System","aria-label":'Permalink to "System"'},"​")],-1),c=s("p",null,"Package system contains some functions about os, runtime, shell command.",-1),r=s("div",{STYLE:"page-break-after: always;"},null,-1),y=s("h2",{id:"Source-",tabindex:"-1"},[a("Source: "),s("a",{class:"header-anchor",href:"#Source-","aria-label":'Permalink to "Source:"'},"​")],-1),i=s("ul",null,[s("li",null,[s("a",{href:"https://github.com/duke-git/lancet/blob/main/system/os.go",target:"_blank",rel:"noreferrer"},"https://github.com/duke-git/lancet/blob/main/system/os.go")])],-1),F=s("div",{STYLE:"page-break-after: always;"},null,-1),u=n(`<h2 id="Usage-" tabindex="-1">Usage: <a class="header-anchor" href="#Usage-" aria-label="Permalink to &quot;Usage:&quot;">​</a></h2><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/system</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/system</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span></code></pre></div>`,2),E=s("div",{STYLE:"page-break-after: always;"},null,-1),d=n('<h2 id="Index" tabindex="-1">Index <a class="header-anchor" href="#Index" aria-label="Permalink to &quot;Index&quot;">​</a></h2><ul><li><a href="#IsWindows">IsWindows</a></li><li><a href="#IsLinux">IsLinux</a></li><li><a href="#IsMac">IsMac</a></li><li><a href="#GetOsEnv">GetOsEnv</a></li><li><a href="#SetOsEnv">SetOsEnv</a></li><li><a href="#RemoveOsEnv">RemoveOsEnv</a></li><li><a href="#CompareOsEnv">CompareOsEnv</a></li><li><a href="#ExecCommand">ExecCommand</a></li><li><a href="#GetOsBits">GetOsBits</a></li></ul>',2),m=s("div",{STYLE:"page-break-after: always;"},null,-1),A=n(`<h2 id="Documentation" tabindex="-1">Documentation <a class="header-anchor" href="#Documentation" aria-label="Permalink to &quot;Documentation&quot;">​</a></h2><h3 id="IsWindows" tabindex="-1"><span id="IsWindows">IsWindows</span> <a class="header-anchor" href="#IsWindows" aria-label="Permalink to &quot;&lt;span id=&quot;IsWindows&quot;&gt;IsWindows&lt;/span&gt;&quot;">​</a></h3><p>Check if current os is windows.</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">IsWindows</span><span style="color:#F6F6F4;">() </span><span style="color:#97E1F1;font-style:italic;">bool</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">IsWindows</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">bool</span></span></code></pre></div><p><b>Example:<span style="float:right;display:inline-block;"><a href="https://go.dev/play/p/zIflQgZNuxD" target="_blank" rel="noreferrer">Run</a></span></b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/system</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    isOsWindows </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> system.</span><span style="color:#97E1F1;">IsWindows</span><span style="color:#F6F6F4;">()</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(isOsWindows)</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/system</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">isOsWindows</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> system</span><span style="color:#999999;">.</span><span style="color:#998418;">IsWindows</span><span style="color:#999999;">()</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">isOsWindows</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="IsLinux" tabindex="-1"><span id="IsLinux">IsLinux</span> <a class="header-anchor" href="#IsLinux" aria-label="Permalink to &quot;&lt;span id=&quot;IsLinux&quot;&gt;IsLinux&lt;/span&gt;&quot;">​</a></h3><p>Check if current os is linux.</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">IsLinux</span><span style="color:#F6F6F4;">() </span><span style="color:#97E1F1;font-style:italic;">bool</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">IsLinux</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">bool</span></span></code></pre></div><p><b>Example:<span style="float:right;display:inline-block;"><a href="https://go.dev/play/p/zIflQgZNuxD" target="_blank" rel="noreferrer">Run</a></span></b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/system</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    isOsLinux </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> system.</span><span style="color:#97E1F1;">IsLinux</span><span style="color:#F6F6F4;">()</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(isOsLinux)</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/system</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">isOsLinux</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> system</span><span style="color:#999999;">.</span><span style="color:#998418;">IsLinux</span><span style="color:#999999;">()</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">isOsLinux</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="IsMac" tabindex="-1"><span id="IsMac">IsMac</span> <a class="header-anchor" href="#IsMac" aria-label="Permalink to &quot;&lt;span id=&quot;IsMac&quot;&gt;IsMac&lt;/span&gt;&quot;">​</a></h3><p>Check if current os is macos.</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">IsMac</span><span style="color:#F6F6F4;">() </span><span style="color:#97E1F1;font-style:italic;">bool</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">IsMac</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">bool</span></span></code></pre></div><p><b>Example:<span style="float:right;display:inline-block;"><a href="https://go.dev/play/p/Mg4Hjtyq7Zc" target="_blank" rel="noreferrer">Run</a></span></b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/system</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    isOsMac </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> system.</span><span style="color:#97E1F1;">IsMac</span><span style="color:#F6F6F4;">()</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(isOsMac)</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/system</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">isOsMac</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> system</span><span style="color:#999999;">.</span><span style="color:#998418;">IsMac</span><span style="color:#999999;">()</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">isOsMac</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="GetOsEnv" tabindex="-1"><span id="GetOsEnv">GetOsEnv</span> <a class="header-anchor" href="#GetOsEnv" aria-label="Permalink to &quot;&lt;span id=&quot;GetOsEnv&quot;&gt;GetOsEnv&lt;/span&gt;&quot;">​</a></h3><p>Gets the value of the environment variable named by the key.</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">GetOsEnv</span><span style="color:#F6F6F4;">(key </span><span style="color:#97E1F1;font-style:italic;">string</span><span style="color:#F6F6F4;">) </span><span style="color:#97E1F1;font-style:italic;">string</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">GetOsEnv</span><span style="color:#999999;">(</span><span style="color:#393A34;">key </span><span style="color:#AB5959;">string</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">string</span></span></code></pre></div><p><b>Example:<span style="float:right;display:inline-block;"><a href="https://go.dev/play/p/D88OYVCyjO-" target="_blank" rel="noreferrer">Run</a></span></b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/system</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    err </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> system.</span><span style="color:#97E1F1;">SetOsEnv</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">foo</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">, </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">abc</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    result </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> system.</span><span style="color:#97E1F1;">GetOsEnv</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">foo</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(err)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(result)</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// Output:</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// &lt;nil&gt;</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// abc</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/system</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">err</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> system</span><span style="color:#999999;">.</span><span style="color:#998418;">SetOsEnv</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">foo</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">abc</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">result</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> system</span><span style="color:#999999;">.</span><span style="color:#998418;">GetOsEnv</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">foo</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">err</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">result</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// Output:</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// &lt;nil&gt;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// abc</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="SetOsEnv" tabindex="-1"><span id="SetOsEnv">SetOsEnv</span> <a class="header-anchor" href="#SetOsEnv" aria-label="Permalink to &quot;&lt;span id=&quot;SetOsEnv&quot;&gt;SetOsEnv&lt;/span&gt;&quot;">​</a></h3><p>Sets the value of the environment variable named by the key.</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">SetOsEnv</span><span style="color:#F6F6F4;">(key, value </span><span style="color:#97E1F1;font-style:italic;">string</span><span style="color:#F6F6F4;">) </span><span style="color:#97E1F1;font-style:italic;">error</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">SetOsEnv</span><span style="color:#999999;">(</span><span style="color:#393A34;">key</span><span style="color:#999999;">,</span><span style="color:#393A34;"> value </span><span style="color:#AB5959;">string</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">error</span></span></code></pre></div><p><b>Example:<span style="float:right;display:inline-block;"><a href="https://go.dev/play/p/D88OYVCyjO-" target="_blank" rel="noreferrer">Run</a></span></b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/system</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    err </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> system.</span><span style="color:#97E1F1;">SetOsEnv</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">foo</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">, </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">abc</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    result </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> system.</span><span style="color:#97E1F1;">GetOsEnv</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">foo</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(err)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(result)</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// Output:</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// &lt;nil&gt;</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// abc</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/system</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">err</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> system</span><span style="color:#999999;">.</span><span style="color:#998418;">SetOsEnv</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">foo</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">abc</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">result</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> system</span><span style="color:#999999;">.</span><span style="color:#998418;">GetOsEnv</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">foo</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">err</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">result</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// Output:</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// &lt;nil&gt;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// abc</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="RemoveOsEnv" tabindex="-1"><span id="RemoveOsEnv">RemoveOsEnv</span> <a class="header-anchor" href="#RemoveOsEnv" aria-label="Permalink to &quot;&lt;span id=&quot;RemoveOsEnv&quot;&gt;RemoveOsEnv&lt;/span&gt;&quot;">​</a></h3><p>Remove a single environment variable.</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">RemoveOsEnv</span><span style="color:#F6F6F4;">(key </span><span style="color:#97E1F1;font-style:italic;">string</span><span style="color:#F6F6F4;">) </span><span style="color:#97E1F1;font-style:italic;">error</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">RemoveOsEnv</span><span style="color:#999999;">(</span><span style="color:#393A34;">key </span><span style="color:#AB5959;">string</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">error</span></span></code></pre></div><p><b>Example:<span style="float:right;display:inline-block;"><a href="https://go.dev/play/p/fqyq4b3xUFQ" target="_blank" rel="noreferrer">Run</a></span></b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/system</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    err1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> system.</span><span style="color:#97E1F1;">SetOsEnv</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">foo</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">, </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">abc</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    result1 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">GetOsEnv</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">foo</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    err2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> system.</span><span style="color:#97E1F1;">RemoveOsEnv</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">foo</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    result2 </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#97E1F1;">GetOsEnv</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">foo</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(err1)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(err2)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(result1)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(result2)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// Output:</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// &lt;nil&gt;</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// &lt;nil&gt;</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// abc</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">//</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/system</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">err1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> system</span><span style="color:#999999;">.</span><span style="color:#998418;">SetOsEnv</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">foo</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">abc</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">result1</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">GetOsEnv</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">foo</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">err2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> system</span><span style="color:#999999;">.</span><span style="color:#998418;">RemoveOsEnv</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">foo</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">result2</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#998418;">GetOsEnv</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">foo</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">err1</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">err2</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">result1</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">result2</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// Output:</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// &lt;nil&gt;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// &lt;nil&gt;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// abc</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">//</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="CompareOsEnv" tabindex="-1"><span id="CompareOsEnv">CompareOsEnv</span> <a class="header-anchor" href="#CompareOsEnv" aria-label="Permalink to &quot;&lt;span id=&quot;CompareOsEnv&quot;&gt;CompareOsEnv&lt;/span&gt;&quot;">​</a></h3><p>Get env named by the key and compare it with comparedEnv.</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">CompareOsEnv</span><span style="color:#F6F6F4;">(key, comparedEnv </span><span style="color:#97E1F1;font-style:italic;">string</span><span style="color:#F6F6F4;">) </span><span style="color:#97E1F1;font-style:italic;">bool</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">CompareOsEnv</span><span style="color:#999999;">(</span><span style="color:#393A34;">key</span><span style="color:#999999;">,</span><span style="color:#393A34;"> comparedEnv </span><span style="color:#AB5959;">string</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">bool</span></span></code></pre></div><p><b>Example:<span style="float:right;display:inline-block;"><a href="https://go.dev/play/p/BciHrKYOHbp" target="_blank" rel="noreferrer">Run</a></span></b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/system</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    err </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> system.</span><span style="color:#97E1F1;">SetOsEnv</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">foo</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">, </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">abc</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#F286C4;">if</span><span style="color:#F6F6F4;"> err </span><span style="color:#F286C4;">!=</span><span style="color:#F6F6F4;"> </span><span style="color:#BF9EEE;">nil</span><span style="color:#F6F6F4;"> {</span></span>
<span class="line"><span style="color:#F6F6F4;">        </span><span style="color:#F286C4;">return</span></span>
<span class="line"><span style="color:#F6F6F4;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    result </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> system.</span><span style="color:#97E1F1;">CompareOsEnv</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">foo</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">, </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">abc</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(result)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// Output:</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// true</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/system</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">err</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> system</span><span style="color:#999999;">.</span><span style="color:#998418;">SetOsEnv</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">foo</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">abc</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#1E754F;">if</span><span style="color:#393A34;"> err </span><span style="color:#AB5959;">!=</span><span style="color:#393A34;"> </span><span style="color:#1E754F;">nil</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">        </span><span style="color:#1E754F;">return</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#999999;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">result</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> system</span><span style="color:#999999;">.</span><span style="color:#998418;">CompareOsEnv</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">foo</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">abc</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">result</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// Output:</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// true</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="ExecCommand" tabindex="-1"><span id="ExecCommand">ExecCommand</span> <a class="header-anchor" href="#ExecCommand" aria-label="Permalink to &quot;&lt;span id=&quot;ExecCommand&quot;&gt;ExecCommand&lt;/span&gt;&quot;">​</a></h3><p>Execute shell command, return the stdout and stderr string of command, and error if error occur. param \`command\` is a complete command string, like, ls -a (linux), dir(windows), ping 127.0.0.1. In linux, use /bin/bash -c to execute command, In windows, use powershell.exe to execute command.</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">type</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">	Option </span><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;">(</span><span style="color:#F286C4;">*</span><span style="color:#F6F6F4;">exec.Cmd)</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">ExecCommand</span><span style="color:#F6F6F4;">(command </span><span style="color:#97E1F1;font-style:italic;">string</span><span style="color:#F6F6F4;">, opts </span><span style="color:#F286C4;">...</span><span style="color:#F6F6F4;">Option) (stdout, stderr </span><span style="color:#97E1F1;font-style:italic;">string</span><span style="color:#F6F6F4;">, err </span><span style="color:#97E1F1;font-style:italic;">error</span><span style="color:#F6F6F4;">)</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">type</span><span style="color:#393A34;"> (</span></span>
<span class="line"><span style="color:#393A34;">	Option </span><span style="color:#1E754F;">func</span><span style="color:#999999;">(</span><span style="color:#AB5959;">*</span><span style="color:#393A34;">exec</span><span style="color:#999999;">.</span><span style="color:#393A34;">Cmd</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">)</span></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">ExecCommand</span><span style="color:#999999;">(</span><span style="color:#393A34;">command </span><span style="color:#AB5959;">string</span><span style="color:#999999;">,</span><span style="color:#393A34;"> opts </span><span style="color:#AB5959;">...</span><span style="color:#393A34;">Option</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span><span style="color:#393A34;">stdout</span><span style="color:#999999;">,</span><span style="color:#393A34;"> stderr </span><span style="color:#AB5959;">string</span><span style="color:#999999;">,</span><span style="color:#393A34;"> err </span><span style="color:#AB5959;">error</span><span style="color:#999999;">)</span></span></code></pre></div><p><b>Example:<span style="float:right;display:inline-block;"><a href="https://go.dev/play/p/n-2fLyZef-4" target="_blank" rel="noreferrer">Run</a></span></b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/system</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// linux or mac</span></span>
<span class="line"><span style="color:#F6F6F4;">    stdout, stderr, err </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> system.</span><span style="color:#97E1F1;">ExecCommand</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">ls</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">std out: </span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">, stdout)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">std err: </span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">, stderr)</span></span>
<span class="line"><span style="color:#F6F6F4;">    assert.</span><span style="color:#97E1F1;">Equal</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;&quot;</span><span style="color:#F6F6F4;">, stderr)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// windows</span></span>
<span class="line"><span style="color:#F6F6F4;">    stdout, stderr, err </span><span style="color:#F286C4;">=</span><span style="color:#F6F6F4;"> system.</span><span style="color:#97E1F1;">ExecCommand</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">dir</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">std out: </span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">, stdout)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">std err: </span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">, stderr)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#7B7F8B;">// error command</span></span>
<span class="line"><span style="color:#F6F6F4;">    stdout, stderr, err </span><span style="color:#F286C4;">=</span><span style="color:#F6F6F4;"> system.</span><span style="color:#97E1F1;">ExecCommand</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">abc</span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">std out: </span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">, stdout)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(</span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">std err: </span><span style="color:#DEE492;">&quot;</span><span style="color:#F6F6F4;">, stderr)</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#F286C4;">if</span><span style="color:#F6F6F4;"> err </span><span style="color:#F286C4;">!=</span><span style="color:#F6F6F4;"> </span><span style="color:#BF9EEE;">nil</span><span style="color:#F6F6F4;"> {</span></span>
<span class="line"><span style="color:#F6F6F4;">        fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(err.</span><span style="color:#97E1F1;">Error</span><span style="color:#F6F6F4;">())</span></span>
<span class="line"><span style="color:#F6F6F4;">    }</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/system</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// linux or mac</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">stdout</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#B07D48;">stderr</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#B07D48;">err</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> system</span><span style="color:#999999;">.</span><span style="color:#998418;">ExecCommand</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">ls</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">std out: </span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">,</span><span style="color:#393A34;"> stdout</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">std err: </span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">,</span><span style="color:#393A34;"> stderr</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    assert</span><span style="color:#999999;">.</span><span style="color:#998418;">Equal</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;&quot;</span><span style="color:#999999;">,</span><span style="color:#393A34;"> stderr</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// windows</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">stdout</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#B07D48;">stderr</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#B07D48;">err</span><span style="color:#393A34;"> </span><span style="color:#999999;">=</span><span style="color:#393A34;"> system</span><span style="color:#999999;">.</span><span style="color:#998418;">ExecCommand</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">dir</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">std out: </span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">,</span><span style="color:#393A34;"> stdout</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">std err: </span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">,</span><span style="color:#393A34;"> stderr</span><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#A0ADA0;">// error command</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">stdout</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#B07D48;">stderr</span><span style="color:#999999;">,</span><span style="color:#393A34;"> </span><span style="color:#B07D48;">err</span><span style="color:#393A34;"> </span><span style="color:#999999;">=</span><span style="color:#393A34;"> system</span><span style="color:#999999;">.</span><span style="color:#998418;">ExecCommand</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">abc</span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">std out: </span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">,</span><span style="color:#393A34;"> stdout</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">std err: </span><span style="color:#B5695999;">&quot;</span><span style="color:#999999;">,</span><span style="color:#393A34;"> stderr</span><span style="color:#999999;">)</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#1E754F;">if</span><span style="color:#393A34;"> err </span><span style="color:#AB5959;">!=</span><span style="color:#393A34;"> </span><span style="color:#1E754F;">nil</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">        fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">err</span><span style="color:#999999;">.</span><span style="color:#998418;">Error</span><span style="color:#999999;">())</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#999999;">}</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h3 id="GetOsBits" tabindex="-1"><span id="GetOsBits">GetOsBits</span> <a class="header-anchor" href="#GetOsBits" aria-label="Permalink to &quot;&lt;span id=&quot;GetOsBits&quot;&gt;GetOsBits&lt;/span&gt;&quot;">​</a></h3><p>Get current os bits, 32bit or 64bit. return 32 or 64</p><p><b>Signature:</b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">GetOsBits</span><span style="color:#F6F6F4;">() </span><span style="color:#97E1F1;font-style:italic;">int</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">GetOsBits</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#AB5959;">int</span></span></code></pre></div><p><b>Example:<span style="float:right;display:inline-block;"><a href="https://go.dev/play/p/ml-_XH3gJbW" target="_blank" rel="noreferrer">Run</a></span></b></p><div class="language-go vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">go</span><pre class="shiki dracula-soft vp-code-dark"><code><span class="line"><span style="color:#F286C4;">import</span><span style="color:#F6F6F4;"> (</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">fmt</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/system</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#F286C4;">func</span><span style="color:#F6F6F4;"> </span><span style="color:#62E884;">main</span><span style="color:#F6F6F4;">() {</span></span>
<span class="line"><span style="color:#F6F6F4;">    osBit </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> system.</span><span style="color:#97E1F1;">GetOsBits</span><span style="color:#F6F6F4;">()</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(osBit) </span><span style="color:#7B7F8B;">// 32 or 64</span></span>
<span class="line"><span style="color:#F6F6F4;">}</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">import</span><span style="color:#393A34;"> </span><span style="color:#999999;">(</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">fmt</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/system</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#999999;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#1E754F;">func</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span><span style="color:#999999;">()</span><span style="color:#393A34;"> </span><span style="color:#999999;">{</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">osBit</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> system</span><span style="color:#999999;">.</span><span style="color:#998418;">GetOsBits</span><span style="color:#999999;">()</span></span>
<span class="line"><span style="color:#393A34;">    fmt</span><span style="color:#999999;">.</span><span style="color:#998418;">Println</span><span style="color:#999999;">(</span><span style="color:#393A34;">osBit</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">// 32 or 64</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div>`,55),g=[t,c,r,y,i,F,u,E,d,m,A];function h(v,f,q,B,b,D){return p(),o("div",null,g)}const O=l(e,[["render",h]]);export{C as __pageData,O as default};
