教程集 www.jiaochengji.com
教程集 >  Golang编程  >  golang教程  >  正文 设计ini配置文件格式

设计ini配置文件格式

发布时间:2021-12-07   编辑:jiaochengji.com
教程集为您提供设计ini配置文件格式等资源,欢迎您收藏本站,我们将为您提供最新的设计ini配置文件格式资源
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;"><path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"/></svg>

下载第三方库

<pre><code>go get github.com/go-ini/ini </code></pre>

设定一个配置文件格式:

<pre><code>[proxy] path="/a" pass="http://localhost:9091" </code></pre>

go读取配置文件:

<pre><code class="lang-go hljs"><span class="token keyword">func</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{ </span> <span class="token comment">//加载配置文件env.ini(参照上面配置文件格式)</span> config<span class="token punctuation">,</span> err <span class="token operator">:=</span> ini<span class="token punctuation">.</span><span class="token function">Load</span><span class="token punctuation">(</span><span class="token string">"env.ini"</span><span class="token punctuation">)</span> <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{ </span></code></pre> 到此这篇关于“设计ini配置文件格式”的文章就介绍到这了,更多文章或继续浏览下面的相关文章,希望大家以后多多支持JQ教程网!

您可能感兴趣的文章:
设计ini配置文件格式
如何进行python的ini文件修改?
python 配置文件如何使用
构建可配置PHP应用程序的正确方式
golang几种常用配置文件使用方法总结(yaml、toml、json、xml、ini)
php读取与修改自定义配置文件的代码
golang读取配置文件
C# Winform 操作 INI 配置文件的实现代码
Asf PHP开发之配置信息常驻系统内存
c# Winform 操作INI配置文件的代码

[关闭]
~ ~