func check(pr proxy??) { // how do I correctly specify a global variable so that it is passed to the function
var proxystr = strings.Split(":", proxy)
}
how can i pass a variable proxy to check function?
Hi. Alll global variables is available everywhere in the same package. The exception is if they are shadowed by a local variable with the same name. If a global variable is exported, begins with capital letter is it also visible in all packages importing the package.
Links below are two different examples of what you are looking to do. The first one will be if you are looking to pass in the slice into a function. The second one is if you are building structs and assigning the function as a method.
Either way, I would try to follow an excellent restricted variable scope to prevent code confusion and overlap. Good luck.