Skip to content

Instantly share code, notes, and snippets.

@owulveryck
Created February 1, 2023 15:12
Show Gist options
  • Save owulveryck/cd49dc82ae8b3bbfaf510821c489fbbf to your computer and use it in GitHub Desktop.
Save owulveryck/cd49dc82ae8b3bbfaf510821c489fbbf to your computer and use it in GitHub Desktop.

Revisions

  1. owulveryck created this gist Feb 1, 2023.
    1 change: 1 addition & 0 deletions AAA README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    cat data | go run main.go
    4 changes: 4 additions & 0 deletions data
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    person1
    person2
    person3
    person4
    22 changes: 22 additions & 0 deletions main.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    package main

    import (
    "bufio"
    "fmt"
    "os"
    )

    func main() {
    s := bufio.NewScanner(os.Stdin)
    s.Split(bufio.ScanLines)
    entries := make(map[string]struct{})
    for s.Scan() {
    entries[s.Text()] = struct{}{}
    }
    separator := [2]string{" \u2615 ", "\n"}
    i := 0
    for k := range entries {
    fmt.Printf("@%v%v", k, separator[i%len(separator)])
    i++
    }
    }