Can't access a function in another file [newbie question]

blov · · 654 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p><a href="http://i.imgur.com/FHuGcV4.png">http://i.imgur.com/FHuGcV4.png</a></p> <p>I&#39;m pulling my hair out here... I&#39;m sure I&#39;m doing something wrong.</p> <p>I have a main.go file in one directory, and in another directory adjacent to the main directory, a file that has an exported struct, and a method on that struct (both capitalized). The compiler can see the struct just fine, but for some reason I can not access the method. Screenshot attached for simplicity.</p> <p>What am I doing wrong?</p> <hr/>**评论:**<br/><br/>togamans: <pre><p>the method should be p.SayHello() not lib.SayHello() since it&#39;s a method on the object.</p></pre>potatofloss: <pre><p>Of course! I knew I was being dense. Thanks!</p></pre>gohacker: <pre><p>What IDE/editor is on the screenshot?</p></pre>rpk788: <pre><p>Looks like IntelliJ probably with the Golang plugin:</p> <p><a href="https://github.com/mtoader/go-lang-idea-plugin#how-to-use-it" rel="nofollow">https://github.com/mtoader/go-lang-idea-plugin#how-to-use-it</a></p></pre>

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

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