Go: x/tools/godoc, go.dev: URL at end of sentence inside brackets causes trailing period to get incorrectly included in the URL

Created on 3 Mar 2020  路  6Comments  路  Source: golang/go

The link in the documentation for the Mutex.Lock() method includes a trailing period. This results in a 404 page when clicked. Inspecting the source, the attribute of interest is:

<a href="https://golang.org/issue/20803.">https://golang.org/issue/20803.</a> 

The fix for this should just be to remove the trailing period in the comment used to generate the documentation, ~which is what is being done elsewhere~.

NeedsInvestigation Tools pkgsite

Most helpful comment

Thanks for reporting.

We should see if this can be fixed in godoc instead. The text in the documentation seems valid. It's a sentence that ends with a period, and a URL happens to be at the end of that sentence. The sentence is inside round brackets.

I suspect the round brackets are making it not recognize the period at the end of a sentence.

If we can fix this in godoc, that means a lot of Go documentation doesn't have to change to avoid this pitfall. I suspect there's more code in the wild that has a similar pattern.

The issue is currently happening at https://pkg.go.dev/cmd/go/internal/lockedfile and https://golang.org/pkg/cmd/go/internal/lockedfile/ as well.

All 6 comments

Change https://golang.org/cl/221937 mentions this issue: cmd/go/internal/lockedfile: remove trailing period for godoc

Thanks for reporting.

We should see if this can be fixed in godoc instead. The text in the documentation seems valid. It's a sentence that ends with a period, and a URL happens to be at the end of that sentence. The sentence is inside round brackets.

I suspect the round brackets are making it not recognize the period at the end of a sentence.

If we can fix this in godoc, that means a lot of Go documentation doesn't have to change to avoid this pitfall. I suspect there's more code in the wild that has a similar pattern.

The issue is currently happening at https://pkg.go.dev/cmd/go/internal/lockedfile and https://golang.org/pkg/cmd/go/internal/lockedfile/ as well.

which is what is being done elsewhere

Can you point out where you're referring to?

@dmitshur I misspoke about this being done elsewhere, I had noticed other places where we didn't include the trailing period when referencing an issue in a comment (such as src/cmd/go/internal/lockedfile/internal/filelock/filelock_fcntl.go:16) but didn't realize that they weren't being included in the documentation.

Thanks for clarifying.

Change https://golang.org/cl/221940 mentions this issue: go/doc: update url matcher to exclude trailing chars

Was this page helpful?
0 / 5 - 0 ratings