Go: x/tools/cmd/godoc: link from filename to source code

Created on 15 Sep 2016  路  10Comments  路  Source: golang/go

Can for example src/net/http/client.go be made clickable so you can navigate more easily through the source code instead of changing the url in the urlbar manually?
image
godoc.org has a navigation menu and also links to the golang.org source code but once you are in the src file you have no navigation.

I am asking this because when you learn Go you end up easely in src files using the golang.org search field to look up golang stuff, for example https://golang.org/search?q=request

EDIT: One of the suggestions I can think of for the example https://golang.org/src/net/http/client.go

Source file src/net/http/client.go    Pakage name http <- https://golang.org/pkg/net/http/
- https://golang.org/src/net/http/
- https://golang.org/src/net/
- https://golang.org/src/

the left side we navigate the src files on the right side we have the general package link

FrozenDueToAge NeedsFix help wanted

Most helpful comment

Latest screenshot (grey text for the last segment that is not a link, similar to godoc.org):
screenshot

All 10 comments

Sounds fine.

CL https://golang.org/cl/29279 mentions this issue.

The CL above (https://golang.org/cl/29279) makes net and http segments of

Source file src/net/http/client.go

clickable. E.g., if you click on the http segment you will be taken to the pkg/http page. Is this what we are looking for here?

@siadat what ever feels the most convenient. Take https://godoc.org/net/http navigation just as a example. The way to implement is open to any suggestions or methods.

src => https://golang.org/src/net/http/client.go
src => https://golang.org/src/net/http/
src => https://golang.org/src/net/
src => https://golang.org/src/
pkg => https://golang.org/pkg/net/http/

image

Let me know the navigation scheme below makes sense to everybody for the following page
https://golang.org/src/net/http/client.go

Source file src/net/http/client.go    Package name http <- https://golang.org/pkg/net/http/
- https://golang.org/src/net/http/
- https://golang.org/src/net/
- https://golang.org/src/

So on the left side we navigate the src files on the right side we have the general package link

Thanks @gertcuykens. I updated the CL.

Before

before-screenshot

After

after-screenshot

The source file segments are clickable. In the second screenshot I am hovering on http.

Regarding the look of it, I used <h2> subtitle for the link to documentation because it was already available in the HTML template.

Looks awesome! :D thanks, PS how can I test it ?

Get the go tools

go get golang.org/x/tools/...

Fetch and install the CL

cd $GOPATH/src/golang.org/x/tools
git fetch https://go.googlesource.com/tools refs/changes/79/29279/4 && git checkout FETCH_HEAD
go install ./...

Run it!

godoc -http=:6060

For any CL, the fetch command could be found in the Download menu of the CL in Gerrit.

@siadat nailed it! This is waaaaay better now to navigate trough source code and it even works wel on mobile too! Please put this in milestone Go1.8 instead of Go1.8Maybe

Latest screenshot (grey text for the last segment that is not a link, similar to godoc.org):
screenshot

Was this page helpful?
0 / 5 - 0 ratings