2020-05-25 02:23:16 +03:00
|
|
|
/* Yes program implementation. */
|
|
|
|
package uniq
|
|
|
|
|
|
|
|
import(
|
|
|
|
"os"
|
|
|
|
"fmt"
|
|
|
|
"bufio"
|
|
|
|
"io"
|
2024-05-15 21:07:35 +03:00
|
|
|
"surdeus.su/core/cli/mtool"
|
2020-05-25 02:23:16 +03:00
|
|
|
)
|
|
|
|
|
2023-03-24 16:54:51 +03:00
|
|
|
func Run(flagSet *mtool.Flags) {
|
2020-05-25 02:23:16 +03:00
|
|
|
var(
|
|
|
|
Uflag bool
|
|
|
|
)
|
|
|
|
flagSet.BoolVar(&Uflag, "U", false, "Print every line just one time.")
|
2023-03-24 16:54:51 +03:00
|
|
|
flagSet.Parse()
|
|
|
|
//args := flagSet.Args()
|
2020-05-25 02:23:16 +03:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|