Skip to content
This repository has been archived by the owner on May 2, 2018. It is now read-only.

Commit

Permalink
strings.Bytes -> []byte for documentation example, src/pkg/* comments…
Browse files Browse the repository at this point in the history
…, and htmlgen.go

R=rsc, adg
CC=golang-dev
https://golang.org/cl/224087
  • Loading branch information
mirtchovski authored and adg committed Mar 2, 2010
1 parent 6d0f1fe commit 1f3222a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
3 changes: 1 addition & 2 deletions doc/effective_go.html
Original file line number Diff line number Diff line change
Expand Up @@ -2435,7 +2435,6 @@ <h2 id="web_server">A web server</h2>
"http"
"io"
"log"
"strings"
"template"
)

Expand All @@ -2460,7 +2459,7 @@ <h2 id="web_server">A web server</h2>
}

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))))
}


Expand Down
19 changes: 9 additions & 10 deletions doc/htmlgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@ import (
"bytes";
"log";
"os";
"strings";
)

var (
lines = make([][]byte, 0, 10000); // assume big enough
linebuf = make([]byte, 10000); // assume big enough

empty = strings.Bytes("");
newline = strings.Bytes("\n");
tab = strings.Bytes("\t");
quote = strings.Bytes(`"`);
empty = []byte("");
newline = []byte("\n");
tab = []byte("\t");
quote = []byte(`"`);

sectionMarker = strings.Bytes("----\n");
preStart = strings.Bytes("<pre>");
preEnd = strings.Bytes("</pre>\n");
pp = strings.Bytes("<p>\n");
sectionMarker = []byte("----\n");
preStart = []byte("<pre>");
preEnd = []byte("</pre>\n");
pp = []byte("<p>\n");
);

func main() {
Expand Down Expand Up @@ -119,7 +118,7 @@ func headings() {
b := bufio.NewWriter(os.Stdout);
for i, l := range lines {
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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/compress/zlib/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ to a buffer:
var b bytes.Buffer
w, err := zlib.NewDeflater(&b)
w.Write(strings.Bytes("hello, world\n"))
w.Write([]byte("hello, world\n"))
w.Close()
and to read that data back:
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/websocket/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func newClient(resourceName, host, origin, location, protocol string, rwc io.Rea
if err != nil {
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())
}
var msg = make([]byte, 512);
Expand Down

0 comments on commit 1f3222a

Please sign in to comment.