Skip to content

Instantly share code, notes, and snippets.

@lojikil
Created September 20, 2016 21:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lojikil/58342b5ea8b4d9fb4516a7104d6f2b21 to your computer and use it in GitHub Desktop.
Save lojikil/58342b5ea8b4d9fb4516a7104d6f2b21 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"os"
"bufio"
"strings"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
lines := make(map[string][]string)
for scanner.Scan() {
parts := strings.Split(scanner.Text(), ":")
lines[parts[0]] = append(lines[parts[0]], parts[1])
}
for key := range lines {
value := strings.Join(lines[key], ", ")
fmt.Printf("- _%s_ line(s): %s\n", key, value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment