Don't make missing providers-config fatal on first-run (#527)

* fix readme golang demo for v2.5.0

* Don't make missing providers-config fatal on first-run

It's okay if we fall back to the default config
which is in memory & will get saved out when done
parsing.

This is on top of the work in #526, but a slightly
different issue.

See: https://github.com/projectdiscovery/subfinder/pull/526
Signed-off-by: Sam James <sam@gentoo.org>

Co-authored-by: Sandeep Singh <sandeep@projectdiscovery.io>
Co-authored-by: zhangchengguo <zhangchengguo@360.cn>
dev
Sam James 2022-04-04 17:33:08 +01:00 committed by GitHub
parent 64dc230104
commit 9a438c5eb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -1,6 +1,9 @@
package runner
import (
"errors"
"os"
"github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/subfinder/v2/pkg/passive"
"github.com/projectdiscovery/subfinder/v2/pkg/resolve"
@ -44,7 +47,9 @@ func (options *Options) loadProvidersFrom(location string) {
}
options.Providers = &Providers{}
if err := options.Providers.UnmarshalFrom(location); isFatalErr(err) {
// We skip bailing out if file doesn't exist because we'll create it
// at the end of options parsing from default via goflags.
if err := options.Providers.UnmarshalFrom(location); isFatalErr(err) && !errors.Is(err, os.ErrNotExist) {
gologger.Fatal().Msgf("Could not read providers from %s: %s\n", location, err)
}
}