FAQ
Reviewers: rsc,

Message:
Hello rsc (cc: golang-dev@googlegroups.com),

I'd like you to review this change to
https://code.google.com/p/go


Description:
go/doc: trim only first space or newline from example output comment

Fixes issue 4487.

Please review this at https://codereview.appspot.com/7057048/

Affected files:
M src/pkg/go/doc/example.go


Index: src/pkg/go/doc/example.go
===================================================================
--- a/src/pkg/go/doc/example.go
+++ b/src/pkg/go/doc/example.go
@@ -84,7 +84,12 @@
// test that it begins with the correct prefix
text := last.Text()
if loc := outputPrefix.FindStringIndex(text); loc != nil {
- return strings.TrimSpace(text[loc[1]:])
+ text = text[loc[1]:]
+ // Strip first space or newline.
+ if len(text) > 0 && (text[0] == ' ' || text[0] == '\n') {
+ text = text[1:]
+ }
+ return text
}
}
return "" // no suitable comment found

Search Discussions

  • Rsc at Jan 7, 2013 at 2:25 am
    LGTM

    Make it 'zero or more spaces followed by \n or a single space'.


    https://codereview.appspot.com/7057048/
  • Adg at Jan 7, 2013 at 2:44 am
    *** Submitted as
    https://code.google.com/p/go/source/detail?r=94f0ce1a6b70 ***

    go/doc: trim only first space or newline from example output comment

    Fixes issue 4487.

    R=rsc
    CC=golang-dev
    https://codereview.appspot.com/7057048


    https://codereview.appspot.com/7057048/
  • Andrew Gerrand at Jan 7, 2013 at 2:47 am

    On 7 January 2013 13:44, wrote:

    go/doc: trim only first space or newline from example output comment

    Damn. I forgot to update the change description. The comment and code was
    updated, though.
  • Russ Cox at Jan 7, 2013 at 3:42 am
    The code looks like it strips all leading spaces up to the first
    non-space, eating the \n if that's the non-space. That's fine too.
  • Andrew Gerrand at Jan 7, 2013 at 3:51 am

    On 7 January 2013 14:42, Russ Cox wrote:

    The code looks like it strips all leading spaces up to the first
    non-space, eating the \n if that's the non-space.
    And equivalent to the wording you suggested, right?
  • Russ Cox at Jan 7, 2013 at 3:53 am
    I was suggesting / | +\n/ but you did / *\n?/. Yours is probably better.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedJan 7, '13 at 2:18a
activeJan 7, '13 at 3:53a
posts7
users2
websitegolang.org

2 users in discussion

Andrew Gerrand: 4 posts Russ Cox: 3 posts

People

Translate

site design / logo © 2022 Grokbase