V
V
Vladimir Grabko2016-09-04 21:30:38
go
Vladimir Grabko, 2016-09-04 21:30:38

How to execute os/exec command relative to another directory?

There is an exec.Command that downloads a file to the same directory where the binary is. Is it possible to run a command relative to another directory?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
uvelichitel, 2016-09-04
@VGrabko

cwd, err = os.Getwd()
err = os.Chdir("/куда/хотите/грузить")
exec.Command(...)
err = os.Chdir("cwd")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question