fix panic resolver's configuration file does not have read permission
This commit is contained in:
committed by
Alec Thomas
parent
d4dd709445
commit
5fd7249c69
+9
-2
@@ -329,9 +329,16 @@ func Configuration(loader ConfigurationLoader, paths ...string) Option {
|
||||
return OptionFunc(func(k *Kong) error {
|
||||
k.loader = loader
|
||||
for _, path := range paths {
|
||||
if _, err := os.Stat(ExpandPath(path)); os.IsNotExist(err) {
|
||||
continue
|
||||
f, err := os.Open(ExpandPath(path))
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) || os.IsPermission(err) {
|
||||
continue
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
f.Close()
|
||||
|
||||
resolver, err := k.LoadConfig(path)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, path)
|
||||
|
||||
Reference in New Issue
Block a user