Created
December 1, 2022 13:25
-
-
Save kenjoe41/ac82e36e4cba39434c2c2326681f1b47 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" | |
| "strings" | |
| ) | |
| func main() { | |
| // Use a map to store the unique URL directories we find | |
| dirs := make(map[string]bool) | |
| // Read the URLs from standard input | |
| var url string | |
| for { | |
| // Read the next URL | |
| _, err := fmt.Scanln(&url) | |
| if err != nil { | |
| break | |
| } | |
| // Extract the directory from the URL | |
| parts := strings.Split(url, "/") | |
| dir := strings.Join(parts[:len(parts)-1], "/") | |
| // Add the directory to our map if it's not already there | |
| if !dirs[dir] { | |
| dirs[dir] = true | |
| fmt.Println(dir) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment