Skip to content

Instantly share code, notes, and snippets.

@iBug
Last active April 12, 2023 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iBug/e5b079e8da527488f97a98fcd8311cc5 to your computer and use it in GitHub Desktop.
Save iBug/e5b079e8da527488f97a98fcd8311cc5 to your computer and use it in GitHub Desktop.
Find Docker containers with autogenerated names
package main
import (
"bufio"
"fmt"
"os"
"regexp"
"strings"
)
func main() {
ls := strings.Join(left[:], "|")
rs := strings.Join(right[:], "|")
re := regexp.MustCompile(fmt.Sprintf("\\b(%s)_(%s)\\b", ls, rs))
s := bufio.NewScanner(os.Stdin)
for s.Scan() {
t := re.FindString(s.Text())
if t != "" {
fmt.Println(t)
}
}
}
main: main.go names-generator.go
go build -o $@ $^
names-generator.go:
wget -O $@ https://github.com/moby/moby/raw/master/pkg/namesgenerator/names-generator.go
sed -i '/^package /c\package main' $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment