Last active
April 12, 2023 13:25
-
-
Save iBug/e5b079e8da527488f97a98fcd8311cc5 to your computer and use it in GitHub Desktop.
Find Docker containers with autogenerated names
This file contains 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 ( | |
"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) | |
} | |
} | |
} |
This file contains 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
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