any way to export nested packages? FFI

blov · · 393 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<pre><code>. ├── __pycache__ │ └── runner.cpython-36.pyc ├── cpuprofile ├── csvTools │ ├── constantsDev.go │ ├── csvSources.go │ └── csvTools.go ├── main.go ├── runner.py </code></pre> <p>Lets say I have the above directory structure. Currently I only know how to export functions via <code>main.go</code>. However id like to pull functions outside of my <code>csvSources.go</code> file without having to literally copy and paste functions into main just for the sake of exporting. Is there any way to do this? </p> <p>Here is my build command <code>go build -buildmode=c-shared -o csvTools.so main.go</code></p> <p><strong>Edit:</strong> I am not talking about capitalizing something. I am talking about the <code>//export</code> comment for FFI -&gt; c shared libraries. </p> <hr/>**评论:**<br/><br/>0xjnml: <pre><p>A thing is exported from a package, which is a directory, not a file, if it&#39;s a top-level declaration, name of which starts with a capital letter (Uncode category Lu, IIRC). Where the package is located in the filesystem tree does not matter as long as its located anywhere under $PATH/src. The location however defines the import path that one must use to import the exported things. The import path is the absolute directory path with the $PATH/src prefix removed.</p> <p>edit: s/filem/file,/, s/i&#39;ts/it&#39;s/</p></pre>maximus12793: <pre><p>I am talking about exporting to a c library which is why I put FFI in the title. Please see my edit</p></pre>

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

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