3 ms·
> So as it currently stands I have no idea what those modules are and what am I loading? vim25? Is that the text editor vim? Take any of these imports, append
by q3k 6y ago
> So as it currently stands I have no idea what those modules are and what am I loading? vim25? Is that the text editor vim?
Take any of these imports, append it to https://godoc.org/ https://godoc.org/, and see.
For example, github.com/vmware/govmomi/ becomes http://godoc.org/github.com/vmware/govmomi/ http://godoc.org/github.com/vmware/govmomi/ , which tells you:
govmovi: A Go library for interacting with VMware vSphere APIs (ESXi and/or vCenter).
Everything underneath govmovi is subpackages of it, so `find`, `view`, `vim25/mo`, and `vim25/types` are all govmovi packages. You can also visit them on godoc to read documentation, if the code authors followed documentation best practices.
These are imports like in any other language. They are, however, nearly always based on a global URL, and thus have a godoc page that you can visit and read the docs for immediately. They are also always qualified, so if you wanna find all all uses of govmovi/vim25/mo, just C-f for "mo." in your codebase. No `from foo import *` equivalent exists in Go, which is one of my favourite features of this language.
- doublerabbit 6y agoSure. Fair to say that godocs is to cpan of perl. But Go doesn't present you the code on disk. I have to hunt somewhere else with a reference. With a library file, I know that prometheus::exporter::blah is related to the perl module prometherus, exporter subroutine blah I need the code in front of me to understand how it's interacting; the whole github ruins that for me.
- hnlmorg 6y ago> But Go doesn't present you the code on disk. Yes it does. You couldn't compile the modules if they weren't on disk :)
- doublerabbit 6y agoBut only at compile time.
- q3k 6y ago`go mod download`, if you're using go modules, will fetch you the deps. This is no different, to me, than downloading a tarball of Python software with requirements.txt and not running setup.py or pip install. I don't understand the problem.
- doublerabbit 6y agoRight, then it could be I wasn't aware there is a "go mod download". If it actually gives me a file I can modify without having to create any repo, special things to apply the changes then that will assist me in the future. Go isn't my thing and the less time I play with it, the happier I am. This is only my experience of it, and my experience is it acts friendly, but is a faff.
- hnlmorg 6y ago> the less time I play with it, the happier I am. There lies the problem. If you don't want to invest the time to learn the tools then you can't really complain that your screwdriver is rubbish at hammering in nails. And it doesn't matter how easy or hard any programming language is, all languages will have a learning curve that people need to be prepared to undertake.
- doublerabbit 6y agoIt's not that I don't want to, it's more I don't have the time to invest upon. I'd read all the national library books if I could, but I just don't have the time. End of shift, I walk away from my screen and try to do something other than. I'm burnt out enough by the tech field as it is.
- q3k 6y agoIt seems to me that the problem here is your job, not Go. You could substitute Go here for any other language or technology that you don't know well and for which you're not given adequate time to learn the basics of, and you'd get the exact same result.
- q3k 6y agoIf you want to read the code, each godoc name can be clicked to directly redirect you to the source code of what you're looking for, eg. to a github page code viewer. Depending on whether you use gomodules, GOPATH, or any other build system you also can find the files locally to grep through them or use your text editor to read them locally. You can also override import resolution to point to a fork (eg. of any module if using gomodules), if you want to test drive some local patches. I do a _ton_ of code reading in my work, and I find using Godoc for that probably the best experience of any language (second only to maybe Haskell/Hoogle, but there you get much more difficult-to-grok-at-a-glance code).
- doublerabbit 6y ago> You can also override import resolution to point to a fork (eg. of any module if using gomodules), if you want to test drive some local patches. So much overhead where time is limited. I shouldn't need to fork packages, I don't want to fork.
- q3k 6y agoIt's one `cp -r` and a 1 line change in go.mod [1]. You can also just `go mod vendor` to have all modules land in a `vendor/` directory when you can edit things as you wish [2]. [1] - https://golang.org/ref/mod#go-mod-file-replace https://golang.org/ref/mod#go-mod-file-replace [2] - https://golang.org/ref/mod#vendoring https://golang.org/ref/mod#vendoring