* Uzair Ally <mua...@gmail.com> [201027 14:19]:
> Hi Jake,
> 
> The code I posted is the runnable go program just missing the powershell 
> script which is a separate file. Maybe I'm miss understanding? Is there 
> something else I can provide to help you understand further?

Based on the your original message and the description you gave later, I
believe my second message will do what you want; i.e.

    out, err := exec.Command(cmdName, "script.ps1").Output()

without quotes around cmdName (a variable containing the string
"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe") and
with quotes around "script.ps1" (the name of the script to run as a
string, not a variable containing a string).

> On Tuesday, October 27, 2020 at 1:26:53 PM UTC-4 mua...@gmail.com wrote:
>> If I add script.ps1 in double quotes and try to run, it tells me cmdName 
>> declared but no used.
>> Yes, the script is named script.ps1. The script is not a variable.

In your original code, the compiler recognizes that script is an
identifier that has not been declared and tells you so.  At that point,
it has not yet done the analysis to determine if all declared variables
are being used; that analysis happens at a later step in the
compilation, which never occurs if errors are found in prior compilation
steps.

Once you fix the errors in the prior compilation steps (in this case
changing script.ps1 from an undeclared identifier to a string), now the
compiler can perform its "unused variable" analysis, and finds cmdName
declared, but not used.  This is because where you intended to use it,
you put it in quotes, making it a string rather than a variable
reference.

...Marvin

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/20201027183736.nv6vc2kd3nt2vv6t%40basil.wdw.

Reply via email to