diff --git a/config/config.go b/config/config.go index 15e6f9b..b465430 100644 --- a/config/config.go +++ b/config/config.go @@ -13,6 +13,7 @@ var ( configType = "json" configFile = "config.json" configPaths []string + defaultEnvName = "P2PRC" ) type Config struct { @@ -64,10 +65,20 @@ func Copy(src, dst string) error { // GetPathP2PRC Getting P2PRC Directory from environment variable func GetPathP2PRC()(string,error) { - curDir := os.Getenv("P2PRC") + curDir := os.Getenv(defaultEnvName) return curDir + "/", nil } +// SetEnvName Sets the environment name +// This is to ensure that the Path of your project is detected from +// your environment variable +// This is useful when extending the use case of P2PRC +func SetEnvName(EnvName string) error { + defaultEnvName = EnvName + // Handling error to be implemented only if needed + return nil +} + // GetCurrentPath Getting P2PRC Directory from environment variable func GetCurrentPath()(string,error) { curDir := os.Getenv("PWD") diff --git a/config/config_test.go b/config/config_test.go index c88ffb8..2f9857f 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -2,6 +2,7 @@ package config import ( "fmt" + "os" "testing" ) @@ -36,3 +37,27 @@ func TestGetPathP2PRC(t *testing.T) { } fmt.Println(path) } + +func TestSetEnvName(t *testing.T) { + // Create an Env variable TEST with the value "lol" + err := os.Setenv("TEST", "lol") + if err != nil { + fmt.Println(err) + t.Error(err) + } + // Sets the environment variable as the default to read + // for P2PRC + err = SetEnvName("TEST") + if err != nil { + fmt.Println(err) + t.Error(err) + } + + // Checks if the output for the default read is "lol" + path, err := GetPathP2PRC() + if err != nil { + fmt.Println(err) + t.Error(err) + } + fmt.Println(path) +} \ No newline at end of file diff --git a/index.html b/index.html index 113ae9c..4635b5e 100644 --- a/index.html +++ b/index.html @@ -30,13 +30,13 @@
  • Only for v1.0.0
    - IP Address: 172.104.44.195 +

    Use this server to only download part of the p2p network

  • Master branch
    - IP Address: 139.162.246.221 +

    Use this server to only download part of the p2p network