Expand tilde to home directory

后端 未结 5 2246
北海茫月
北海茫月 2020-12-06 04:06

I have a program that accepts a destination folder where files will be created. My program should be able to handle absolute paths as well as relative paths. My problem is t

5条回答
  •  再見小時候
    2020-12-06 04:20

    I know this is an old question but there is another option now. You can use go-homedir to expand the tidle to the user's homedir:

    myPath := "~/.ssh"
    fmt.Printf("path: %s; with expansion: %s", myPath, homedir.Expand(myPath))
    

提交回复
热议问题