godoc/static: mimic the pre-1.10 behavior of strconv.Quote

Thanks to iant for identifying the root cause.

Tested with go1.9 and go1.10.

Fixes golang/go#25880

Change-Id: Ibc3a2aadd92c1e512cf6c537134ee085398e8e6c
Reviewed-on: https://go-review.googlesource.com/118955
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Alan Donovan 2018-06-14 15:07:04 -04:00
parent 49ce10d933
commit 903a227b9b
2 changed files with 9 additions and 3 deletions

View File

@ -88,7 +88,15 @@ func Generate() ([]byte, error) {
fmt.Fprintf(buf, ",\n\n") fmt.Fprintf(buf, ",\n\n")
} }
fmt.Fprintln(buf, "}") fmt.Fprintln(buf, "}")
return format.Source(buf.Bytes())
b := buf.Bytes()
// The 鿥 U+9FE5 character became printable in go 1.10,
// causing it to appear literally in newer output.
// Force the old behavior.
b = bytes.Replace(b, []byte("\u9fe5"), []byte(`\u9fe5`), -1)
return format.Source(b)
} }
// sanitize prepares a valid UTF-8 string as a raw string constant. // sanitize prepares a valid UTF-8 string as a raw string constant.

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//+build go1.10
package static package static
import ( import (