coder/websocket

Inline part of the full examples

3052 opened this issue · 7 comments

If you follow the link comment you'll see the example.

If not please let me know. Worked for me just tried it.

3052 commented

I code Go both professionally and personally, and this is the first time I have ever seen an example like this:

package main

import ()

func main() {
	// https://github.com/nhooyr/websocket/tree/master/internal/examples/echo
}

why not just code the examples inline, like the rest:
https://godocs.io/nhooyr.io/websocket#example-package-CrossOrigin

It's a multi file example with tests. Such examples cannot be effectively included inline with godoc. At least not to my knowledge.

Perhaps it would be worth having the echo.go file inline though and also link to the full runnable example.

3052 commented

I mean if you are getting to the point where you examples are multiple files, it might be better to just link to the GitHub folder where the example are. but just do a normal link to the folder, putting a link inside a Go program just seems wrong.

I mean if you are getting to the point where you examples are multiple files, it might be better to just link to the GitHub folder where the example are. but just do a normal link to the folder, putting a link inside a Go program just seems wrong.

Problem is such links are not easily identifiable unless you read the full godoc which many people do not do. This way, it's easily identifiable as part of the godoc UI.

3052 commented

OK, well put the link/links the VERY top of the doc, that way its unlikely to be missed