I have this working in another programming language, creating a url to reverse geocode a location. I am new to Go and I am slowly working building up the script.
I have the method Geofunction(x,y) with the two variables x & y From another method I call the above method and supply the values to the variables.
I just can't get it to work as expected.
Could someone point me to where to help me find the answer give me some help on this please.
I have a working coy in Python, as I learn Go I am translating scripts understand.
I have made changes to allow certain variable to accessible to the other functions. I need to understand if the method called with be able to access the variable values.
package main
import "fmt"
var Location1x, Location1y string
var Location1 string
var rev_geo string
func Geofunction(x, y) {
var str1 string = "https://eu1.locationiq.com/v1/reverse.php?key="
var str2 string = "**********************" //API Key
var str3 string = x // '48.853106'
var str4 string = "&lon="
var str5 string = y // '2.384202'
var str6 string = "&format=json"
var rev_geo string = str1 + str2 + str3 + str4 + str5 + str6
return rev_geo
}
func Locator() {
Location1x, Location1y = "48.853106", "2.384202"
Location1 = Geofunction(Location1x, Location1y)
}
func main() {
Locator()
fmt.Println(Location1)
}```
Expected:
A string of a URL is printed.
The three errors are:
main.go:9:18: undefined: x
main.go:9:21: undefined: y
Geofunction(Location1x, Location1y) used as value
Once I get the above sorted, I will then reuse the method to produce multiple strings in an API test that confirms specific data in the json files returned from the server