From ab84639aaaaf8f29b3864cdf54db4667e1357473 Mon Sep 17 00:00:00 2001 From: V2Ray Date: Fri, 9 Oct 2015 16:48:05 +0200 Subject: [PATCH] prototype of platform specific code --- common/platform/others.go | 16 ++++++++++++++++ common/platform/platform.go | 10 ++++++++++ common/platform/windows.go | 17 +++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 common/platform/others.go create mode 100644 common/platform/platform.go create mode 100644 common/platform/windows.go diff --git a/common/platform/others.go b/common/platform/others.go new file mode 100644 index 00000000..a0d25a5e --- /dev/null +++ b/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) +} diff --git a/common/platform/platform.go b/common/platform/platform.go new file mode 100644 index 00000000..a35f0fc4 --- /dev/null +++ b/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) +} diff --git a/common/platform/windows.go b/common/platform/windows.go new file mode 100644 index 00000000..4a6ae7b8 --- /dev/null +++ b/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 +}