Help GoLand multifile main?

xuanbao · · 487 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I split my main.go file into multiple files for organization, but i can&#39;t seems to get GoLand to allow me to build it... it errors with something like</p> <pre><code> .\Main.go:12:5: undefined: functionA .\Main.go:13:13: undefined: functionB .\Main.go:13:24: undefined: functionC </code></pre> <hr/>**评论:**<br/><br/>dlsniper: <pre><p>Go to Run | Edit Configurations select the run configuration you created and instead of Run Kind file, use Run Kind package. See: <a href="https://youtu.be/ko-wKntCLjg" rel="nofollow">https://youtu.be/ko-wKntCLjg</a> for a visual guide of this. Please note that the linkmode is needed only in special cases, it&#39;s entirely optional.</p></pre>SaturnsVoid: <pre><p>thanks! this worked!</p></pre>gngeorgiev: <pre><p>I guess you have the files in the same package, next to main.go. In the go build arguments you need to pass all files of the main package. In the cli it would look like <code>go build *.go</code>. Should be something like this in goland</p></pre>kusrabs: <pre><p>Probably function names in another file should start from capital Letter, not letter.</p></pre>dlsniper: <pre><p>In Go all files in a package (directory) belong to the same package (except for the _test test named packages, in _test.go files). So it doesn&#39;t matter how the functions are named.</p></pre>

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

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