-
Notifications
You must be signed in to change notification settings - Fork 0
/
godoc.html
394 lines (211 loc) · 9.56 KB
/
godoc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
using GOPATH mode
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#375EAB">
<title>ini - Go Documentation Server</title>
<link type="text/css" rel="stylesheet" href="doc/style.css">
<script>window.initFuncs = [];</script>
<script src="doc/jquery.js" defer></script>
<script>var goVersion = "go1.15.2";</script>
<script src="doc/godocs.js" defer></script>
</head>
<body>
<div id='lowframe'
style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
...
</div><!-- #lowframe -->
<div id="topbar" class="wide">
<div class="container">
<div class="top-heading" id="heading-wide"><a href="/pkg/">Go Documentation Server</a></div>
<div class="top-heading" id="heading-narrow"><a href="/pkg/">GoDoc</a></div>
<a href="#" id="menu-button"><span id="menu-button-arrow">▽</span></a>
<form method="GET" action="/search">
<div id="menu">
<span class="search-box"><input type="search" id="search" name="q" placeholder="Search"
aria-label="Search" required><button type="submit"><span>
<!-- magnifying glass: --><svg width="24" height="24" viewBox="0 0 24 24">
<title>submit search</title>
<path
d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" />
<path d="M0 0h24v24H0z" fill="none" />
</svg></span></button></span>
</div>
</form>
</div>
</div>
<div id="page" class="wide">
<div class="container">
<h1>
Package ini
<span class="text-muted"></span>
</h1>
<div id="nav"></div>
<!--
Copyright 2009 The Go Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<!--
Note: Static (i.e., not template-generated) href and id
attributes start with "pkg-" to make it impossible for
them to conflict with generated attributes (some of which
correspond to Go identifiers).
-->
<script>
document.ANALYSIS_DATA = null;
document.CALLGRAPH = null;
</script>
<div id="short-nav">
<dl>
<dd><code>import "github.com/github-user/ini"</code></dd>
</dl>
<dl>
<dd><a href="#pkg-overview" class="overviewLink">Overview</a></dd>
<dd><a href="#pkg-index" class="indexLink">Index</a></dd>
</dl>
</div>
<!-- The package's Name is printed as title by the top-level template -->
<div id="pkg-overview" class="toggleVisible">
<div class="collapsed">
<h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
</div>
<div class="expanded">
<h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
<p>
Package ini 包实现了读取简单 ini 文件的功能,
并且提供了对应的接口函数,用来监听配置文件是否被修改等一些特定的时间
让开发者自己决定处理配置变化,最终返回一个新的配置文件数据结构。
</p>
</div>
</div>
<div id="pkg-index" class="toggleVisible">
<div class="collapsed">
<h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
</div>
<div class="expanded">
<h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
<!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
<div id="manual-nav">
<dl>
<dd><a href="#pkg-variables">Variables</a></dd>
<dd><a href="#Config">type Config</a></dd>
<dd> <a href="#Load">func Load(filename string) (*Config, error)</a></dd>
<dd> <a href="#Watch">func Watch(filename string, listener Listener) (*Config,
error)</a></dd>
<dd><a href="#ListenFunc">type ListenFunc</a></dd>
<dd><a href="#Listener">type Listener</a></dd>
<dd><a href="#Section">type Section</a></dd>
</dl>
</div><!-- #manual-nav -->
<h3>Package files</h3>
<p>
<span style="font-size:90%">
<a href="/src/github.com/github-user/ini/file.go">file.go</a>
<a href="/src/github.com/github-user/ini/parser.go">parser.go</a>
<a href="/src/github.com/github-user/ini/section.go">section.go</a>
</span>
</p>
</div><!-- .expanded -->
</div><!-- #pkg-index -->
<h2 id="pkg-variables">Variables</h2>
<pre>var (
<span class="comment">// DefaultSection is the name of default section. You can use this constant or the string literal.</span>
<span class="comment">// In most of cases, an empty string is all you need to access the section.</span>
<span id="DefaultSection">DefaultSection</span> = "DEFAULT"
<span class="comment">// KeyValueDelim is a string which contents all possiable delimiter symbols</span>
<span id="KeyValueDelim">KeyValueDelim</span> = "="
<span class="comment">// CommentSym based on running os to set ';' or '#'</span>
<span id="CommentSym">CommentSym</span> = "#"
<span class="comment">// LineBreak is the delimiter to determine or compose a new line.</span>
<span class="comment">// This variable will be changed to "\r\n" automatically on Windows at package init time.</span>
<span id="LineBreak">LineBreak</span> = "\n"
)</pre>
<h2 id="Config">type <a href="/src/github.com/github-user/ini/file.go?s=1413:1542#L29">Config</a>
<a class="permalink" href="#Config">¶</a>
</h2>
<p>
Config represents a INI files in memory
</p>
<p>
Config 结构将 ini 文件,以特定的形式将文件内容保存在内存中
</p>
<pre>type Config struct {
<span class="comment">// To keep data in order.</span>
<span id="Config.SecList"></span> SecList []<a href="/pkg/builtin/#string">string</a>
<span class="comment">// Actual data is stored here.</span>
<span id="Config.Sections"></span> Sections map[<a href="/pkg/builtin/#string">string</a>]*<a href="#Section">Section</a>
}
</pre>
<h3 id="Load">func <a href="/src/github.com/github-user/ini/file.go?s=1694:1737#L39">Load</a>
<a class="permalink" href="#Load">¶</a>
</h3>
<pre>func Load(filename <a href="/pkg/builtin/#string">string</a>) (*<a href="#Config">Config</a>, <a href="/pkg/builtin/#error">error</a>)</pre>
<p>
Load ini file, return error if exists
</p>
<p>
Load 函数读取 ini 文件,根据文件内容返回 Config 结构指针或可能产生的错误。
</p>
<h3 id="Watch">func <a href="/src/github.com/github-user/ini/file.go?s=1101:1164#L17">Watch</a>
<a class="permalink" href="#Watch">¶</a>
</h3>
<pre>func Watch(filename <a href="/pkg/builtin/#string">string</a>, listener <a href="#Listener">Listener</a>) (*<a href="#Config">Config</a>, <a href="/pkg/builtin/#error">error</a>)</pre>
<p>
Watch ini-file if some event happened then it returns a new Config pointer and error
</p>
<p>
Watch 函数接收一个 Listener 接口,函数会调用其中的 listen 函数,用于监听特定事件发生。
当事件发生后,线程从 listen 函数返回,重新执行 Load 函数返回新的 Config 指针或可能产生的错误。
</p>
<h2 id="ListenFunc">type <a href="/src/github.com/github-user/ini/file.go?s=725:753#L11">ListenFunc</a>
<a class="permalink" href="#ListenFunc">¶</a>
</h2>
<p>
ListenFunc a default type to implement Listener interface
</p>
<p>
ListenFunc 是 Listener 接口的一个默认实现结构,可以将实现的 listen 函数转换成该类型传入 watch 函数
</p>
<pre>type ListenFunc func(<a href="/pkg/builtin/#string">string</a>)</pre>
<h2 id="Listener">type <a href="/src/github.com/github-user/ini/file.go?s=477:526#L6">Listener</a>
<a class="permalink" href="#Listener">¶</a>
</h2>
<p>
Listener interface used in watch function
</p>
<p>
Listener 接口使用在 watch 函数中,其中的 listen 函数用于监听特定事件的发生
</p>
<pre>type Listener interface {
<span class="comment">// contains filtered or unexported methods</span>
}</pre>
<h2 id="Section">type <a href="/src/github.com/github-user/ini/section.go?s=170:238#L1">Section</a>
<a class="permalink" href="#Section">¶</a>
</h2>
<p>
Section in ini file with keyVal map
</p>
<p>
Section 数据结构提供了 KeyVal 字段,可用通过 key 字符串映射到 value 字符串
</p>
<pre>type Section struct {
<span id="Section.KeyList"></span> KeyList []<a href="/pkg/builtin/#string">string</a>
<span id="Section.KeyVal"></span> KeyVal map[<a href="/pkg/builtin/#string">string</a>]<a href="/pkg/builtin/#string">string</a>
}
</pre>
<div id="footer">
Build version go1.15.2.<br>
Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
the content of this page is licensed under the
Creative Commons Attribution 3.0 License,
and code is licensed under a <a href="/LICENSE">BSD license</a>.<br>
<a href="/doc/tos.html">Terms of Service</a> |
<a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
</div>
</div><!-- .container -->
</div><!-- #page -->
</body>
</html>