X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=ns.go;h=34e075d9fc684ab3080cce5caf9bca1ee9194f64;hb=HEAD;hp=af1159f39262f4b6a23f0aac8a325284345e56af;hpb=b8868fafef88a7b8320d6e68a3c4c4697950d1e1;p=netstring.git diff --git a/ns.go b/ns.go index af1159f..34e075d 100644 --- a/ns.go +++ b/ns.go @@ -1,19 +1,17 @@ -/* -netstring -- netstring format serialization library -Copyright (C) 2015-2020 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 -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ +// netstring -- netstring format serialization library +// Copyright (C) 2015-2024 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 +// the Free Software Foundation, version 3 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . // netstring format serialization library. // @@ -21,15 +19,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