Godoc / Local Project/ Documentation

289 views
Skip to first unread message

Rejoy

unread,
Mar 5, 2017, 4:12:19 PM3/5/17
to golang-nuts
In my local project folder (a web app) that has the go source files, I use the go run command to get the output. Each of these files is called a package main. I 'd like to create the documentation for the project. I run godoc -http=:6060, but don't see any of the source files of my local project. All I see is the list of subdirectories.
What would be the correct way to do the documentation of the local project .
Thanks




Shawn Milochik

unread,
Mar 5, 2017, 6:43:12 PM3/5/17
to golang-nuts
You can append this to the URL:

?m=src

So this:


becomes



You can still only see exported functions. If you pull out the code you want to document into packages (other than "main") then they will be documented normally. You're running into this problem because you're doing something non-standard -- having a bunch of separate "main" applications in a single folder. I don't know how/if the above will work on a folder with multiple files containing "func main," though.


Rejoy

unread,
Mar 6, 2017, 1:00:32 AM3/6/17
to golang-nuts
Yes, this works and suffices my needs for now. So if I understand right, I should be creating just the single main package and import all other files as packages into the main package. Only then will the documentation show up for my local project as well.
Reply all
Reply to author
Forward
0 new messages