godoc for built-in functions?

256 views
Skip to first unread message

Dan Adkins

unread,
May 26, 2011, 1:24:47 PM5/26/11
to golang-nuts
This morning, I wanted to look up the documentation for copy, so I
typed "godoc copy" into my terminal, which obviously didn't work.
Eventually I found what I was looking for in the language spec, but I
wish godoc could answer my simple questions about built-in functions
like what's their signature, or how do I use them.

-Dan

Steven

unread,
May 26, 2011, 1:44:08 PM5/26/11
to Dan Adkins, golang-nuts


What if I had a package called copy? It would be perfectly legal, if
ill-advised. Maybe godoc runtime copy, but that might clach with the C
function. godoc -builtin copy? Anyways, godoc is for package
documentation. You should look in the language spec for information
about built-ins. I'm not sure that having godoc cover do too many
tricks is such a good idea...

Jan Mercl

unread,
May 26, 2011, 1:45:20 PM5/26/11
to golan...@googlegroups.com
-1. Godoc has no knowledge of "things" not found in Go source files. Otherwise it may become a (probably unusable) silver bullet with language specs, FAQ, etc. ad send mail ;)

andrey mirtchovski

unread,
May 26, 2011, 1:48:37 PM5/26/11
to Steven, Dan Adkins, golang-nuts
one could have a stub "builtin" package with just the documentation
for those functions. the package need not be compiled. that would
allow builtins to be found through golang.org/pkg/builtin too.

at any rate, those are but a handful and I doubt anyone paying more
than a cursory glance to the language would have trouble remembering
them.

Dan Adkins

unread,
May 26, 2011, 1:59:49 PM5/26/11
to golang-nuts
Silly me for wanting stuff to be convenient and *just work*. I think
godoc is wonderful. I wish it were as easy to lookup documentation
about built-in functions. That is all.

-Dan

Anschel Schaffer-Cohen

unread,
May 26, 2011, 2:07:27 PM5/26/11
to golan...@googlegroups.com
Well, godoc -http serves all the Go documentation, including the FAQ, specification, etc.

Anschel Schaffer-Cohen

unread,
May 26, 2011, 2:11:28 PM5/26/11
to golan...@googlegroups.com
The problem, as I see it, is that copy doesn't have a signature, in the Go sense. It's more generic than Go's type system can handle (since it works with strings, slices, arrays, etc.). That's why it's built-in in the first place.

Rob 'Commander' Pike

unread,
May 26, 2011, 5:21:05 PM5/26/11
to golan...@googlegroups.com
This is just an oversight. See
godoc unsafe
There should probably something like
godoc builtin
although not necessarily with that name.

-rob

Dmitry Chestnykh

unread,
May 26, 2011, 5:23:31 PM5/26/11
to golan...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages