where

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 999c2a50deca90a88e320c45447367eb5116ddf5
parent 3865b4ee658eef409abbe5b382e4ee8376e985e2
Author: aabacchus <bvnfuller@gmail.com>
Date:   Fri, 19 Mar 2021 23:13:10 +0000

ignore duplicates in `who`

Diffstat:
Mwhere.go | 23+++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/where.go b/where.go @@ -89,10 +89,25 @@ func parseLines(ips []byte) [][]string { continue } if ip == '\n' { - words[line] = append(words[line], word) - words = append(words, []string{}) - line++ - word = "" + // remove duplicates by username + isDuplicate := false + // no need to check if we're on the first line + if line != 0 { + for _, prevline := range words[:line] { + if words[line][0] == prevline[0] { + isDuplicate = true + } + } + } + if isDuplicate { + words[line] = []string{} + word = "" + } else { + words[line] = append(words[line], word) + words = append(words, []string{}) + line++ + word = "" + } continue } word = word + string(ip)