vot/xkpasswd-go

xkpasswd-words.txt not found when run from a different folder from the executable

glowinthedark opened this issue · 2 comments

The file xkpasswd-words.txt is not found when xkpasswd-go is run from another directory than the folder containing xkpasswd-words.txt or xkpasswd-go.

Copying xkpasswd-words.txt to the same folder where xkpasswd-go is located does not help and the same error is shown

readLines: open xkpasswd-words.txt: no such file or directory

Steps to reproduce:

  1. go get -v -u github.com/vot/xkpasswd-go
  2. cp $GOPATH/src/github.com/vot/xkpasswd-go/xkpasswd-words.txt $GOPATH/bin
  3. xkpasswd-go

output:

readLines: open xkpasswd-words.txt: no such file or directory

If I cd into GOPATH/bin and run the command again then it works as expected:

  1. cd %GOPATH/bin
  2. xkpasswd-go

output:

unpotable.realisms.galvanoplasty
vot commented

Thanks @glowinthedark for raising the issue.
I'll try to fix it soon - it shouldn't be too difficult to inject the directory in which binary is located in the dictionary path.

vot commented

Hi @glowinthedark,

Once again thanks for raising both issues.

I just fixed this issue in this commit:
f95e2d0

Using os.Executable() to get the location of executable file and appending the filename at the end now (instead of current working directory).
Let me know if this fixes it.

Vot