-//type NewsPath struct {
-// Paths []string
-//}
-//
-//func (np *NewsPath) Payload() []byte {
-// var out []byte
-//
-// count := make([]byte, 2)
-// binary.BigEndian.PutUint16(count, uint16(len(np.Paths)))
-//
-// out = append(out, count...)
-// for _, p := range np.Paths {
-// pLen := byte(len(p))
-// out = append(out, []byte{0, 0}...) // what is this?
-// out = append(out, pLen)
-// out = append(out, []byte(p)...)
-// }
-//
-// return out
-//}
-
-func ReadNewsPath(newsPath []byte) []string {
- if len(newsPath) == 0 {
- return []string{}
- }
- pathCount := binary.BigEndian.Uint16(newsPath[0:2])
-
- pathData := newsPath[2:]
- var paths []string
-
- for i := uint16(0); i < pathCount; i++ {
- pathLen := pathData[2]
- paths = append(paths, string(pathData[3:3+pathLen]))
-
- pathData = pathData[pathLen+3:]
+// newsPathScanner implements bufio.SplitFunc for parsing incoming byte slices into complete tokens
+func newsPathScanner(data []byte, _ bool) (advance int, token []byte, err error) {
+ if len(data) < 3 {
+ return 0, nil, nil