Closed pioz closed 2 years ago
Go does not do string environment-variable interpolation. In order to get this you need to expand the value yourself. So: sftp.Create(filepath.Join(os.Getenv("HOME"), "/.config/systemd/user/hello.service"))
Go does not do string environment-variable interpolation. In order to get this you need to expand the value yourself. So:
sftp.Create(filepath.Join(os.Getenv("HOME"), "/.config/systemd/user/hello.service"))
Thanks, but I need the remote os.Getenv("HOME")
not the local home directory.
Use sftp.Client.Getwd()
to get the current working directory from the server, this should default to the user’s home directory.
Thanks, it works! 😗
Use
sftp.Client.Getwd()
to get the current working directory from the server, this should default to the user’s home directory.
why sftp.Client.Getwd()
always reutrn the same directory ? like '/root' , which method could effect this result?
I don't know if this is possible in some way, but what I would like to do is:
using the
$HOME
environment variable.I've tried but I get the error "file does not exist", if instead I use the exploded path "/home/pioz/.config/systemd/user/hello.service" I get no errors.