<p>I'm starting up a project (not a developer) that should read in a config file, process it and keep track of some processed results. I'm thinking a database may be overkill for holding on to these values, is there any easy way to keep track of state?</p>
<p>Should I use the configuration file to hold this or something separate? I can fill in with more details.</p>
<hr/>**评论:**<br/><br/>Mteigers: <pre><p>Go half way and use BoltDB. It's more optimized than querying a config file and doesn't require a database engine to run so you don't sacrifice portability. </p></pre>dmikalova: <pre><p>This is what I'm doing. Super simple and easy once you get the hang of it.</p></pre>jmreicha: <pre><p>Cool, I will check it out. Thanks!</p></pre>RalphCorderoy: <pre><p>If the structure of the processed results is very simple then you could simply write it to a file and read it back in on the next run of the program. Either write that code yourself or look at using an encoder that takes, e.g. a <code>struct</code>, and <em>serialises</em> it for the file. <a href="http://golang.org/pkg/encoding/" rel="nofollow">http://golang.org/pkg/encoding/</a></p></pre>mc_hammerd: <pre><p>yea seralizing your data (to binary) and writing it to disk is the sweet spot between the two.</p></pre>jmreicha: <pre><p>Nice, I will take a look. Thanks!</p></pre>klaaax: <pre><p>Sqlite. why is it overkill? it is not. Sqlite is transactional. if state is important then use it. Be sure to gracefully shut down your executable too in order to do the necessary clean up when things turn south.</p></pre>tehbilly: <pre><p>This is what I'd use more often, if I didn't primarily cross compile. I need to try it more often, broaden my horizons.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传