New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
regexp: add examples for all methods on regex.Regexp #21450
Comments
All yours @shoenig, thank you! |
I'm not sure that's a good idea. The methods are all variations on the same scheme. I don't see how enumerating the possible combinations and generating examples for them adds significant value over what's already there. Please don't expand the docs with content that basically amounts to filler material just to satisfy some notion of exhaustiveness. If it's part of the docs, it should be worth to read. Excessive repetition is a time waster for people learning the API of a package. If you can pull it off to demonstrate a new aspect of the package with every added example, go wild though! |
Change https://golang.org/cl/120145 mentions this issue: |
Change https://golang.org/cl/142197 mentions this issue: |
Thank you @cn007b for adding more examples. Here are some remaining ones for which I think examples would be good to have to keep it consistent with the other examples.
I think once these are done, we can close this bug. The remaining ones are just simple variants of other methods which already have examples. |
@agnivade I created a PR for it. I didn't add an example for |
It's not the default. https://tip.golang.org/pkg/regexp/#Compile is leftmost-first. https://tip.golang.org/pkg/regexp/#CompilePOSIX is the one which is leftmost-longest. |
Change https://golang.org/cl/189137 mentions this issue: |
Change https://golang.org/cl/189138 mentions this issue: |
Change https://golang.org/cl/189177 mentions this issue: |
Updates #21450 Change-Id: Ia31c20b52bae5daeb33d918234c2f0944a8aeb07 GitHub-Last-Rev: cc85544 GitHub-Pull-Request: #33489 Reviewed-on: https://go-review.googlesource.com/c/go/+/189137 Run-TryBot: Sylvain Zimmer <sylvinus@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Updates #21450 Change-Id: Idf276e97f816933cc0f752cdcd5e713b5c975833 GitHub-Last-Rev: 198e585 GitHub-Pull-Request: #33490 Reviewed-on: https://go-review.googlesource.com/c/go/+/189138 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Since I first started on this CL, most of the methods have had examples added by other folks, so this is now one new example, and additions to two existing examples for extra clarity. The issue has a comment about not necessarily having examples for all methods, but I recall finding this package pretty confusing when I first used it, and having concrete examples would have really helped me navigate all the different options. There are more String methods with examples now, but I think seeing how the byte-slice methods work could also be helpful to explain the differences. Updates #21450 Change-Id: I27b4eeb634fb8ab59f791c0961cce79a67889826 Reviewed-on: https://go-review.googlesource.com/c/go/+/120145 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org>
updates #21450 Change-Id: Ibffe0dadc1e1523c55cd5f5b8a69bc1c399a255d GitHub-Last-Rev: 507f555 GitHub-Pull-Request: #33497 Reviewed-on: https://go-review.googlesource.com/c/go/+/189177 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
All of the examples that I outlined have been submitted. I will go ahead and close this now. Thank you everyone who contributed to the examples. |
Something I've been wanting to do for a while is provide complete example coverage for methods defined on regexp.Regex. There are 36 methods, 11 of which have examples. Unless this isn't desired, I'd like to finish the other 25.
The text was updated successfully, but these errors were encountered: