I am getting a physical location address from a user and trying to arrange it to create a URL that would use later to get a JSON response from Google Geocode API.
The final URL string result should be similar to this one, without spaces:
http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true
I do not know how to replace white spaces in my URL string and have commas instead. I did read a little about the strings and regexp packages and I have created the following code:
package main
import (
"fmt"
"bufio"
"os"
"http"
)
func main() {
// Get the physical address
r := bufio.NewReader(os.Stdin)
fmt.Println("Enter a physical location address: ")
line, _, _ := r.ReadLine()
// Print the inputted address
address := string(line)
fmt.Println(address) // Need to see what I'm getting
// Create the URL and get Google's Geocode API JSON response for that address
URL := "http://maps.googleapis.com/maps/api/geocode/json?address=" + address + "&sensor=true"
fmt.Println(URL)
result, _ := http.Get(URL)
fmt.Println(result) // To see what I'm getting at this point
}