Nested1 := func() {
artifact := nested()
log.Println(“Artif:”, artifact)
commands := []string{
“Version=psg **artifact** | cut -d '/' -f16 | cut -d '_' -f2
”,
“echo $Version”,
}
exe_cmd(commands)
return
}
I need to get the artifact value inside my commands
1 Like
lutzhorn
(Lutz Horn)
January 6, 2018, 4:15pm
2
Thank you so much @lutzhorn I need to return this Version value to this Nested1 function. Can you please help me with that as well )
lutzhorn
(Lutz Horn)
January 6, 2018, 6:22pm
4
Then you should return
a value from your func
. Did you work through the Go Tour ?
@lutzhorn yes I know how to return value to function. But I need to know how to return the shell variable to function?
1 Like
@luthzhorn , i have same dought too bcoz, echo $version is a php syntax which can be interpreted in golang but how?
1 Like
lutzhorn
(Lutz Horn)
January 7, 2018, 8:14am
7
What module is the function exe_command
part of? I don’t find it in os/exec
. Do you use some 3rd party package? Which?
The package os/exec
allows you to connect to the pipes STDIN, STDOUT, and STDERR of the subcommand. Take a look at the example of func (*Cmd) StdoutPipe
. This example explains who to read from STDOUT.
geosoft1
(George Calianu)
January 7, 2018, 8:24am
8
See (*Cmd) Output example.
2 Likes
system
(system)
Closed
April 7, 2018, 8:27am
9
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.