From 2bd3ae4de25c17b277f8a81ce07af1e3fcb13bba Mon Sep 17 00:00:00 2001 From: Kartikey Semwal Date: Sun, 8 Sep 2024 15:26:29 +0530 Subject: [PATCH] code review 1 changes --- internal/file/file.go | 4 ++-- pkg/crawler/useragents.go | 5 ++++- pkg/output/output.go | 1 - 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/file/file.go b/internal/file/file.go index 8768e37..498b131 100644 --- a/internal/file/file.go +++ b/internal/file/file.go @@ -84,7 +84,7 @@ func CreateOutputFile(target string, subcommand string, format string, outputDir _, err := os.Stat(filename) if os.IsNotExist(err) { - if _, err := os.Stat(outputDir + "/"); os.IsNotExist(err) { + if _, err := os.Stat(fmt.Sprintf("%s/", outputDir)); os.IsNotExist(err) { CreateOutputFolder(outputDir) } // If the file doesn't exist, create it. @@ -123,7 +123,7 @@ func CreateIndexOutputFile(filename string, outputDir string) { _, err := os.Stat(filename) if os.IsNotExist(err) { - if _, err := os.Stat(outputDir + "/"); os.IsNotExist(err) { + if _, err := os.Stat(fmt.Sprintf("%s/", outputDir)); os.IsNotExist(err) { CreateOutputFolder(outputDir) } // If the file doesn't exist, create it. diff --git a/pkg/crawler/useragents.go b/pkg/crawler/useragents.go index 54385b1..9d02ab6 100644 --- a/pkg/crawler/useragents.go +++ b/pkg/crawler/useragents.go @@ -35,6 +35,10 @@ import ( "time" ) +const ( + maxRandomValue = 100 +) + // genOsString generates a random OS string for a User Agent. func genOsString() string { source := rand.NewSource(time.Now().UnixNano()) @@ -151,7 +155,6 @@ func GenerateRandomUserAgent() string { source := rand.NewSource(time.Now().UnixNano()) rng := rand.New(source) - const maxRandomValue = 100 decision := rng.Intn(maxRandomValue) var ua string diff --git a/pkg/output/output.go b/pkg/output/output.go index 92f553f..619703b 100644 --- a/pkg/output/output.go +++ b/pkg/output/output.go @@ -36,7 +36,6 @@ import ( "github.com/edoardottt/cariddi/pkg/scanner" ) -// constant defined in file.go as well, redefining here for circular dependency. const ( CariddiOutputFolder = "output-cariddi" )