Use os.ExpandEnv for injecting gopath in dict path (#227)

This commit is contained in:
Brendan Le Glaunec
2019-06-15 18:36:35 +02:00
committed by GitHub
parent a5d3455333
commit 4603096b93
2 changed files with 6 additions and 7 deletions
+4 -5
View File
@@ -3,7 +3,6 @@ package cameradar
import (
"fmt"
"os"
"strings"
"time"
"github.com/ullaakut/disgo"
@@ -12,8 +11,8 @@ import (
)
const (
defaultCredentialDictionaryPath = "<GOPATH>/src/github.com/ullaakut/cameradar/dictionaries/credentials.json"
defaultRouteDictionaryPath = "<GOPATH>/src/github.com/ullaakut/cameradar/dictionaries/routes"
defaultCredentialDictionaryPath = "${GOPATH}/src/github.com/ullaakut/cameradar/dictionaries/credentials.json"
defaultRouteDictionaryPath = "${GOPATH}/src/github.com/ullaakut/cameradar/dictionaries/routes"
)
// Scanner represents a cameradar scanner. It scans a network and
@@ -62,8 +61,8 @@ func New(options ...func(*Scanner)) (*Scanner, error) {
disgo.Errorln(style.Failure("No $GOPATH was found.\nDictionaries may not be loaded properly, please set your $GOPATH to use the default dictionaries."))
}
scanner.credentialDictionaryPath = strings.Replace(scanner.credentialDictionaryPath, "<GOPATH>", gopath, 1)
scanner.routeDictionaryPath = strings.Replace(scanner.routeDictionaryPath, "<GOPATH>", gopath, 1)
scanner.credentialDictionaryPath = os.ExpandEnv(scanner.credentialDictionaryPath)
scanner.routeDictionaryPath = os.ExpandEnv(scanner.routeDictionaryPath)
scanner.term = disgo.NewTerminal(
disgo.WithDebug(scanner.debug),