Description of the problem
I want to send a concurrent call to each iteration on my for loop.
Current Code
This program mostly try's to find a valid directory on the server
package main
import (
"bufio"
"fmt"
"net/http"
"os"
)
func main() {
var site string
if len(os.Args) > 1 {
site = os.Args[1]
} else {
fmt.Println("Need the host. Example > http://www.google.com/")
fmt.Println("wfuzz http://www.google.com/ wordlist.txt")
site = "http://www.google.com"
os.Exit(1)
}
f, err := os.Open(os.Args[2])
if err != nil {
fmt.Println("error opening file!", err)
}
scanner := bufio.NewScanner(f)
for scanner.Scan() {
a := site + scanner.Text()
get_page(a)
}
if err := scanner.Err(); err != nil {
fmt.Println("error", err)
}
var input string
fmt.Scanln(&input)
fmt.Println("done")
}
func get_page(site string) string {
a := "\n"
res, err := http.Get(site)
if err != nil {
fmt.Println("error:", err)
}
if res.StatusCode != 404 {
fmt.Println("Page Found!! +::", site, " ::+", res.StatusCode)
}
return a
}
Goal to Achieve
What I want to achieve is mostly send on my for loop concurrent calls that way i would speed up the process and would be the end goal for the current program.