Created
September 20, 2016 21:13
-
-
Save lojikil/58342b5ea8b4d9fb4516a7104d6f2b21 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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