]> Cypherpunks repositories - gostls13.git/commitdiff
strings.Bytes -> []byte for documentation example, src/pkg/* comments, and htmlgen.go
authorAndrey Mirtchovski <mirtchovski@gmail.com>
Tue, 2 Mar 2010 00:18:22 +0000 (11:18 +1100)
committerAndrew Gerrand <adg@golang.org>
Tue, 2 Mar 2010 00:18:22 +0000 (11:18 +1100)
R=rsc, adg
CC=golang-dev
https://golang.org/cl/224087

doc/effective_go.html
doc/htmlgen.go
src/pkg/compress/zlib/reader.go
src/pkg/websocket/client.go

index 684f108de952e63bc699a0574d8b93cf35b06c95..728e07be11f04719a78530e06bf9232c34a80c36 100644 (file)
@@ -2435,7 +2435,6 @@ import (
     "http"
     "io"
     "log"
-    "strings"
     "template"
 )
 
@@ -2460,7 +2459,7 @@ func QR(c *http.Conn, req *http.Request) {
 }
 
 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))))
 }
 
 
index 8d44fc0787b0e7119479c4588f464c458f9d1ed5..e4a2b5293375cec9630d0a498625dff762e17c1f 100644 (file)
@@ -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() {
@@ -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;
                }
        }
index 357a8a337bf8a9b5de3ca5e2993d945ddb83b022..c541a8d508f6152e5f79575bc00dc88fc099f626 100644 (file)
@@ -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:
index 9060f8b2939cff2a8c91462040982c9ff5e9f96e..7bf53d840c341c59bf810a897d9c05549d001095 100644 (file)
@@ -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);