bb/tool/uniq/uniq.go
2024-05-15 23:07:35 +05:00

36 lines
511 B
Go

/* Yes program implementation. */
package uniq
import(
"os"
"fmt"
"bufio"
"io"
"surdeus.su/core/cli/mtool"
)
func Run(flagSet *mtool.Flags) {
var(
Uflag bool
)
flagSet.BoolVar(&Uflag, "U", false, "Print every line just one time.")
flagSet.Parse()
//args := flagSet.Args()
r := bufio.NewReader(os.Stdin)
u := make(map[string]int)
if Uflag {
for{
l, e := r.ReadString('\n')
if e==io.EOF {
break
}
_, haskey := u[l]
if !haskey {
u[l] = 1
fmt.Print(l)
}
}
}
}