Please review my asset program

polaris · · 371 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I wrote a little helper I&#39;d like to have opinions on, its <a href="https://github.com/fabstu/asset" rel="nofollow">https://github.com/fabstu/asset</a>.</p> <p>Its basically a little helper to put node modules into my binary and to easily serve them.</p> <p>Can I do something better?</p> <hr/>**评论:**<br/><br/>tclineks: <pre><p>Aren&#39;t there other established solutions here? gobindata, go.rice, another simpler one I&#39;m not recalling off the top of my head.</p> <p>why write this?</p></pre>sh41: <pre><p>A pretty comprehensive list of tools in this space is at <a href="https://github.com/shurcooL/vfsgen#alternatives" rel="nofollow">https://github.com/shurcooL/vfsgen#alternatives</a>.</p> <p>I created vfsgen. It started by merging go-bindata and go-bindata-assetfs into one and cleaning up/optimizing the result, reducing unnecessary overhead.</p></pre>fabstu: <pre><p>Hey I tried!</p> <p>1) Generate http.Dir vars and Handlers function in ./internal/asset</p> <p>2.1) Call vfsgendev -&gt; failed cause cant read internal</p> <p>2.2) Wrote to non-internal -&gt; worked</p> <p>2.3) Found out tool cant choose package name and write to specific directory.</p> <p>2.4) Switching to directory and calling from there works, albeit still cant change package name this way. Hitting <a href="https://github.com/shurcooL/vfsgen/issues/23" rel="nofollow">https://github.com/shurcooL/vfsgen/issues/23</a>.</p> <p>3) vfsgen.Generate() requires to write a temporary main package cause http.Dir directory is non-main to be usable and I tried doing that but was not so successful, so continued with 2.4</p></pre>fabstu: <pre><p>This wraps the established gobindata-assetfs solution and simplifies the setup alot.</p> <p>Writing gogenerate gobindata-assetfs ... and creating the handlers for the assets gets replaced by <code> //go:generate asset generate --pkg ./internal/asset --node=bootstrap,jquery --mine </code> and <code> asset.Register(true) </code> .</p> <p>I haven&#39;t known of go.rice before, I&#39;ll have a look.</p> <p>Edit: go.rice looks nice, my interface is just for adding node modules at predictable paths, like <code>bootstrap -&gt; /css/boostrap, /js/bootstrap</code> and serving my own assets <code>data/js -&gt; /mine/js data/css -&gt; /mine/css</code>. With go.rice lots more things can be done and is on first glance similar to gobindata, with dynamic searching of resources in serveral locations(binary, ondisk, ..).</p></pre>sh41: <pre><p>Since your solution wraps go-bindata-assetfs, I highly recommend considering vfsgen as the backend. It&#39;s compatible since they both give a standard <code>http.FileSystem</code>.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

371 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传