"http"
"io"
"log"
- "strings"
"template"
)
}
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))))
}
"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() {
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;
}
}
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:
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);