Browse Source

prototype of platform specific code

V2Ray 10 years ago
parent
commit
ab84639aaa
3 changed files with 43 additions and 0 deletions
  1. 16 0
      common/platform/others.go
  2. 10 0
      common/platform/platform.go
  3. 17 0
      common/platform/windows.go

+ 16 - 0
common/platform/others.go

@@ -0,0 +1,16 @@
+// +build !windows
+
+package platform
+
+import (
+	"os"
+)
+
+type otherPlatformEnvironment struct {
+}
+
+var environmentInstance = &otherPlatformEnvironment{}
+
+func (e *otherPlatformEnvironment) ExpandEnv(s string) string {
+	return os.ExpandEnv(s)
+}

+ 10 - 0
common/platform/platform.go

@@ -0,0 +1,10 @@
+// Package platform provides platform specific functionalities.
+package platform
+
+type environment interface {
+	ExpandEnv(s string) string
+}
+
+func ExpandEnv(s string) string {
+	return environmentInstance.ExpandEnv(s)
+}

+ 17 - 0
common/platform/windows.go

@@ -0,0 +1,17 @@
+// +build windows
+
+package platform
+
+import (
+	"os"
+)
+
+type windowsEnvironment struct {
+}
+
+var environmentInstance = &windowsEnvironment{}
+
+func (e *windowsEnvironment) ExpandEnv(s string) string {
+	// TODO
+	return s
+}