X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=ns.go;h=af43bcebb931a1d996d5442c35034fb2d4c4eb17;hb=8fa6c4b0000e2dc27fce9220db1a5eb8bf468e81;hp=340460698707f6e273df7d65b7f1c3b5fa32eaf7;hpb=4a2baae4738ddc9554317c169eaf783600468f7d;p=netstring.git diff --git a/ns.go b/ns.go index 3404606..af43bce 100644 --- a/ns.go +++ b/ns.go @@ -1,6 +1,6 @@ /* netstring -- netstring format serialization library -Copyright (C) 2015-2021 Sergey Matveev +Copyright (C) 2015-2023 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,15 +21,15 @@ along with this program. If not, see . // (http://cr.yp.to/proto/netstrings.txt) format for binary string // serialization. // -// var b bytes.Buffer -// w := netstring.NewWriter(&b) -// n, _ = w.WriteChunk([]byte("hello")) // n is 8, "5:hello," -// n, _ = w.WriteSize(6) // n is 2 -// n, _ = w.Write([]byte("wor")) // n is 3 -// n, _ = w.Write([]byte("ld!")) // n is 3, "5:hello,6:world!," -// r := netstring.NewReader(&b) -// size, err := r.Next() // size is 5 -// r.Discard() // skip that chunk -// size, err = r.Next() // size is 6 -// data, _ := ioutil.ReadAll(r) // data contains "world!" +// var b bytes.Buffer +// w := netstring.NewWriter(&b) +// n, _ = w.WriteChunk([]byte("hello")) // n is 8, "5:hello," +// n, _ = w.WriteSize(6) // n is 2 +// n, _ = w.Write([]byte("wor")) // n is 3 +// n, _ = w.Write([]byte("ld!")) // n is 3, "5:hello,6:world!," +// r := netstring.NewReader(&b) +// size, err := r.Next() // size is 5 +// r.Discard() // skip that chunk +// size, err = r.Next() // size is 6 +// data, _ := io.ReadAll(r) // data contains "world!" package netstring