import{_ as s,o as a,c as n,X as l}from"./chunks/framework.6e839c56.js";const g=JSON.parse('{"title":"安装","description":"","frontmatter":{"outline":"deep"},"headers":[],"relativePath":"guide/getting_started.md","filePath":"guide/getting_started.md"}'),o={name:"guide/getting_started.md"},p=l(`<h1 id="安装" tabindex="-1">安装 <a class="header-anchor" href="#安装" aria-label="Permalink to &quot;安装&quot;">​</a></h1><ol><li><b>使用 go1.18 及以上版本的用户，建议安装 v2.x.x。 因为 v2.x.x 应用 go1.18 的泛型重写了大部分函数。</b></li></ol><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;">go</span><span style="color:#F6F6F4;"> get github.com</span><span style="color:#F286C4;">/</span><span style="color:#F6F6F4;">duke</span><span style="color:#F286C4;">-</span><span style="color:#F6F6F4;">git</span><span style="color:#F286C4;">/</span><span style="color:#F6F6F4;">lancet</span><span style="color:#F286C4;">/</span><span style="color:#F6F6F4;">v2 </span><span style="color:#7B7F8B;">// will install latest version of v2.x.x</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">go</span><span style="color:#393A34;"> get github</span><span style="color:#999999;">.</span><span style="color:#393A34;">com</span><span style="color:#AB5959;">/</span><span style="color:#393A34;">duke</span><span style="color:#AB5959;">-</span><span style="color:#393A34;">git</span><span style="color:#AB5959;">/</span><span style="color:#393A34;">lancet</span><span style="color:#AB5959;">/</span><span style="color:#393A34;">v2 </span><span style="color:#A0ADA0;">// will install latest version of v2.x.x</span></span></code></pre></div><ol start="2"><li><b>使用 go1.18 以下版本的用户，必须安装 v1.x.x。目前最新的 v1 版本是 v1.4.1。</b></li></ol><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;">go</span><span style="color:#F6F6F4;"> get github.com</span><span style="color:#F286C4;">/</span><span style="color:#F6F6F4;">duke</span><span style="color:#F286C4;">-</span><span style="color:#F6F6F4;">git</span><span style="color:#F286C4;">/</span><span style="color:#F6F6F4;">lancet </span><span style="color:#7B7F8B;">// below go1.18, install latest version of v1.x.x</span></span></code></pre><pre class="shiki vitesse-light vp-code-light"><code><span class="line"><span style="color:#1E754F;">go</span><span style="color:#393A34;"> get github</span><span style="color:#999999;">.</span><span style="color:#393A34;">com</span><span style="color:#AB5959;">/</span><span style="color:#393A34;">duke</span><span style="color:#AB5959;">-</span><span style="color:#393A34;">git</span><span style="color:#AB5959;">/</span><span style="color:#393A34;">lancet </span><span style="color:#A0ADA0;">// below go1.18, install latest version of v1.x.x</span></span></code></pre></div><h2 id="用法" tabindex="-1">用法 <a class="header-anchor" href="#用法" aria-label="Permalink to &quot;用法&quot;">​</a></h2><p>lancet 是以包的结构组织代码的，使用时需要导入相应的包名。例如：如果使用字符串相关函数，需要导入 strutil 包:</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 style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">github.com/duke-git/lancet/v2/strutil</span><span style="color:#DEE492;">&quot;</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:#B5695999;">&quot;</span><span style="color:#59873A;">github.com/duke-git/lancet/v2/strutil</span><span style="color:#B5695999;">&quot;</span></span></code></pre></div><h2 id="示例" tabindex="-1">示例 <a class="header-anchor" href="#示例" aria-label="Permalink to &quot;示例&quot;">​</a></h2><p>此处以字符串工具函数 Reverse（逆序字符串）为例，需要导入 strutil 包:</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;">package</span><span style="color:#F6F6F4;"> main</span></span>
<span class="line"></span>
<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/strutil</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;">    s </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> </span><span style="color:#DEE492;">&quot;</span><span style="color:#E7EE98;">hello</span><span style="color:#DEE492;">&quot;</span></span>
<span class="line"><span style="color:#F6F6F4;">    rs </span><span style="color:#F286C4;">:=</span><span style="color:#F6F6F4;"> strutil.</span><span style="color:#97E1F1;">Reverse</span><span style="color:#F6F6F4;">(s)</span></span>
<span class="line"><span style="color:#F6F6F4;">    fmt.</span><span style="color:#97E1F1;">Println</span><span style="color:#F6F6F4;">(rs) </span><span style="color:#7B7F8B;">//olleh</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;">package</span><span style="color:#393A34;"> </span><span style="color:#59873A;">main</span></span>
<span class="line"></span>
<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/strutil</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;">s</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> </span><span style="color:#B5695999;">&quot;</span><span style="color:#B56959;">hello</span><span style="color:#B5695999;">&quot;</span></span>
<span class="line"><span style="color:#393A34;">    </span><span style="color:#B07D48;">rs</span><span style="color:#393A34;"> </span><span style="color:#999999;">:=</span><span style="color:#393A34;"> strutil</span><span style="color:#999999;">.</span><span style="color:#998418;">Reverse</span><span style="color:#999999;">(</span><span style="color:#393A34;">s</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;">rs</span><span style="color:#999999;">)</span><span style="color:#393A34;"> </span><span style="color:#A0ADA0;">//olleh</span></span>
<span class="line"><span style="color:#999999;">}</span></span></code></pre></div><h2 id="More" tabindex="-1">More <a class="header-anchor" href="#More" aria-label="Permalink to &quot;More&quot;">​</a></h2><p>其他特性请参考<a href="https://lancet.go.dev/api/overview.html" target="_blank" rel="noreferrer">API</a>.</p>`,13),e=[p];function t(c,r,i,y,F,d){return a(),n("div",null,e)}const h=s(o,[["render",t]]);export{g as __pageData,h as default};
