I frequently need to go back and look up documentation or declarations to know the type of variables in my code. Am I doing something wrong?

agolangf · 2016-03-30 17:23:04 · 801 次点击    
这是一个分享于 2016-03-30 17:23:04 的资源,其中的信息可能已经有所发展或是发生改变。


评论:

mwholt:

No, but an editor with a Go plugin can help. Sublime: GoSublime+GoImports, Atom: GoPlus, Visual Studio Code: VScode-go. You can also use a editor-agnostic solution like Sourcegraph which I highly recommend.

The more locally-scoped your variables are, the less trouble you will have remembering what their type is.

Injunire:

Also if using vim-go you can use :GoDef to jump right to where the variable is defined.

v1rous:

Having programmed for over a decade, I can tell you there's nothing wrong with that! 60-80% of the time I spend "coding" is actually time spent googling, reading documentation, and just plain thinking.

old_to_me_downvoter:

Nothing wrong with having the only thing you've accomplished for the day is 5 lines of the absolute most perfect (for that situation) code after 7+ hours of research.

adonovan76:

You could try the Guru tool (godoc.org/golang.org/x/tools/cmd/guru), which plugs into many editors. Among other things, it can show the type (and fields and methods) of any expression you select.

forgiv:

I try to name my variables in a way that makes the type more obvious.


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

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