mirror of
https://github.com/golang/go
synced 2024-11-21 18:34:44 -07:00
strings.Bytes -> []byte for documentation example, src/pkg/* comments, and htmlgen.go
R=rsc, adg CC=golang-dev https://golang.org/cl/224087
This commit is contained in:
parent
6d0f1fedbf
commit
1f3222a57b
@ -2435,7 +2435,6 @@ import (
|
|||||||
"http"
|
"http"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
|
||||||
"template"
|
"template"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -2460,7 +2459,7 @@ func QR(c *http.Conn, req *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UrlHtmlFormatter(w io.Writer, v interface{}, fmt string) {
|
func UrlHtmlFormatter(w io.Writer, v interface{}, fmt string) {
|
||||||
template.HTMLEscape(w, strings.Bytes(http.URLEscape(v.(string))))
|
template.HTMLEscape(w, []byte(http.URLEscape(v.(string))))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,22 +15,21 @@ import (
|
|||||||
"bytes";
|
"bytes";
|
||||||
"log";
|
"log";
|
||||||
"os";
|
"os";
|
||||||
"strings";
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
lines = make([][]byte, 0, 10000); // assume big enough
|
lines = make([][]byte, 0, 10000); // assume big enough
|
||||||
linebuf = make([]byte, 10000); // assume big enough
|
linebuf = make([]byte, 10000); // assume big enough
|
||||||
|
|
||||||
empty = strings.Bytes("");
|
empty = []byte("");
|
||||||
newline = strings.Bytes("\n");
|
newline = []byte("\n");
|
||||||
tab = strings.Bytes("\t");
|
tab = []byte("\t");
|
||||||
quote = strings.Bytes(`"`);
|
quote = []byte(`"`);
|
||||||
|
|
||||||
sectionMarker = strings.Bytes("----\n");
|
sectionMarker = []byte("----\n");
|
||||||
preStart = strings.Bytes("<pre>");
|
preStart = []byte("<pre>");
|
||||||
preEnd = strings.Bytes("</pre>\n");
|
preEnd = []byte("</pre>\n");
|
||||||
pp = strings.Bytes("<p>\n");
|
pp = []byte("<p>\n");
|
||||||
);
|
);
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -119,7 +118,7 @@ func headings() {
|
|||||||
b := bufio.NewWriter(os.Stdout);
|
b := bufio.NewWriter(os.Stdout);
|
||||||
for i, l := range lines {
|
for i, l := range lines {
|
||||||
if i > 0 && bytes.Equal(l, sectionMarker) {
|
if i > 0 && bytes.Equal(l, sectionMarker) {
|
||||||
lines[i-1] = strings.Bytes("<h2>" + string(trim(lines[i-1])) + "</h2>\n");
|
lines[i-1] = []byte("<h2>" + string(trim(lines[i-1])) + "</h2>\n");
|
||||||
lines[i] = empty;
|
lines[i] = empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ to a buffer:
|
|||||||
|
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
w, err := zlib.NewDeflater(&b)
|
w, err := zlib.NewDeflater(&b)
|
||||||
w.Write(strings.Bytes("hello, world\n"))
|
w.Write([]byte("hello, world\n"))
|
||||||
w.Close()
|
w.Close()
|
||||||
|
|
||||||
and to read that data back:
|
and to read that data back:
|
||||||
|
@ -57,7 +57,7 @@ func newClient(resourceName, host, origin, location, protocol string, rwc io.Rea
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic("Dial: ", err.String())
|
panic("Dial: ", err.String())
|
||||||
}
|
}
|
||||||
if _, err := ws.Write(strings.Bytes("hello, world!\n")); err != nil {
|
if _, err := ws.Write([]byte("hello, world!\n")); err != nil {
|
||||||
panic("Write: ", err.String())
|
panic("Write: ", err.String())
|
||||||
}
|
}
|
||||||
var msg = make([]byte, 512);
|
var msg = make([]byte, 512);
|
||||||
|
Loading…
Reference in New Issue
Block a user