Add "." in the prefix is how you hide a file on Linux. On Windows, it will use syscall SetFileAttributes to set a folder to "hidden".
In linux build
func isHidden(filename string) (bool, error) { if len(filepath.Base(filename)) > 0 && filepath.Base(filename)[0:1] == "." { return true, nil } return false, nil }
You are checking via
isHidden, err := hidden.IsHidden("./test", false)
It will always end up panic because this file will be renamed to ./.test after hiding it and the above isHidden will never find the file.
./.test
isHidden
For windows it should be working fine with the example in your package.
Ok so there is another package for the windows. There is a small problem in your isHidden method and the example.
Thanks for pointing it out! I will try to fix it soon :D
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Add "." in the prefix is how you hide a file on Linux. On Windows, it will use syscall SetFileAttributes to set a folder to "hidden".
In linux build
You are checking via
It will always end up panic because this file will be renamed to
./.test
after hiding it and the aboveisHidden
will never find the file.For windows it should be working fine with the example in your package.
Ok so there is another package for the windows. There is a small problem in your
isHidden
method and the example.Thanks for pointing it out! I will try to fix it soon :D