<p>I already use package <code>os/exec</code> to <code>get</code> the package I need every time the program is run but I guess that once the "main" file is compiled, all of it's dependancies compile into the binary as well. Is there someway to tell the computer to ignore <code>lib/package</code> and compile it every time the bianary is run?</p>
<hr/>**评论:**<br/><br/>Fwippy: <pre><p>Why?</p></pre>theDamnKid: <pre><p>It's for an application for operation nunya.</p>
<p>as in nunya business.</p>
<hr/>
<p>Now that I got my shitty snarky remark out of the way, I am making a "ban" list for people if they abuse a system on a server. I want to update that list without having to reinstall the program every time.</p></pre>djherbis: <pre><p>You shouldn't need to recompile to update a blacklist. You should use a database, or hot reloading config file for updates like that.</p></pre>kurin: <pre><p>This is an XY problem if I've ever seen one. Jeez.</p></pre>Fwippy: <pre><p>Yeah, I'm glad I asked.</p></pre>Shammyhealz: <pre><p>Just to add on to what djherbis said, you don't want to compile this in because it's going to get loaded into memory. Hence as the block list grows, so does your memory footprint. People could potentially abuse the system again by just creating a ton of accounts, abusing the system, and getting banned until your memory footprint is too large for the server. This is basically going to create a denial of service vector where there doesn't need to be one.</p>
<p>Databases are really want you want for this. Go for SQLite if you don't want to run a separate daemon process, it should be plenty fast enough unless you're banning tons and tons of people.</p>
<p>All that being said, if you're still determined to do it, just write this as a service and write the re-compile step into your init script. Or wrap the binary in a script that does the re-compile.</p></pre>theDamnKid: <pre><p>It's on a linux server of about 150 people. I <strong>might</strong> ban 10. They can't make more accounts so there's that... but sure. thanks for the help.</p></pre>Fwippy: <pre><p>Yeah, I'd probably just go with a <code>blacklist.txt</code> file - have your program read that file to get the list of users to block every time it starts up, so all you have to do is edit that one file.</p></pre>Malangelus: <pre><blockquote>
<p>It's for an application for operation nunya.</p>
<p>as in nunya business.</p>
<hr/>
<p>Now that I got my shitty snarky remark out of the way, I am making a "ban" list for people if they abuse a system on a server. I want to update that list without having to reinstall the program every time.</p>
</blockquote>
<p>What a dickish response to a reasonable question. Your approach is dumb by the way; you shouldn't be recompiling a static hardcoded list for a ban list, that's idiotic. Use a text file or a DB.</p></pre>vruzz: <pre><p>You can't easily self-modify the binary you're running (and it's probably not even possible to mess with in Go during runtime). One approach would be to keep a small launcher that compiles, executes, and does all the juggling.<br/>
Or maybe use readily-existing code to simplify updates
<a href="https://github.com/sanbornm/go-selfupdate" rel="nofollow">https://github.com/sanbornm/go-selfupdate</a></p>
<p>Another approach would be to generate and use dynamically linked libraries, this is a new feature in Go 1.5 <a href="https://golang.org/doc/go1.5" rel="nofollow">https://golang.org/doc/go1.5</a></p>
<p>Take a look here:
<a href="http://www.darkcoding.net/software/building-shared-libraries-in-go-part-1/" rel="nofollow">http://www.darkcoding.net/software/building-shared-libraries-in-go-part-1/</a></p></pre>
Newb here, I was wondering if there was a way to "go get" inside a compiled program.
agolangf · · 648 次点击这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传