36 lines
494 B
Go
36 lines
494 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func main() {
|
|
keys := map[string]bool{}
|
|
for _, k := range os.Args[1:] {
|
|
keys[k] = true
|
|
}
|
|
|
|
s := bufio.NewScanner(os.Stdin)
|
|
|
|
for s.Scan() {
|
|
ss := []string{}
|
|
for _, f := range strings.Fields(s.Text()) {
|
|
kv := strings.Split(f, "=")
|
|
if len(kv) != 2 {
|
|
continue
|
|
}
|
|
k := kv[0]
|
|
if _, ok := keys[k]; !ok {
|
|
continue
|
|
}
|
|
ss = append(ss, f)
|
|
}
|
|
if len(ss) > 0 {
|
|
fmt.Println(strings.Join(ss, " "))
|
|
}
|
|
}
|
|
}
|