From ef06f2f890aa4f20d1ff55da91b29392ba6af3af Mon Sep 17 00:00:00 2001 From: Daniel Theophanes Date: Tue, 7 Feb 2017 11:25:40 -0800 Subject: [PATCH] service: do not call osext if go1.8+ is used --- pre_go1.8.go | 16 ++++++++++++++++ service.go | 10 ---------- service_go1.8.go | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 pre_go1.8.go create mode 100644 service_go1.8.go diff --git a/pre_go1.8.go b/pre_go1.8.go new file mode 100644 index 0000000..56d7fbb --- /dev/null +++ b/pre_go1.8.go @@ -0,0 +1,16 @@ +//+build !go1.8 + +package service + +import ( + "path/filepath" + + "github.com/kardianos/osext" +) + +func (c *Config) execPath() (string, error) { + if len(c.Executable) != 0 { + return filepath.Abs(c.Executable) + } + return osext.Executable() +} diff --git a/service.go b/service.go index c01530f..af90204 100644 --- a/service.go +++ b/service.go @@ -64,9 +64,6 @@ package service // import "github.com/kardianos/service" import ( "errors" "fmt" - "path/filepath" - - "github.com/kardianos/osext" ) const ( @@ -117,13 +114,6 @@ type Config struct { Option KeyValue } -func (c *Config) execPath() (string, error) { - if len(c.Executable) != 0 { - return filepath.Abs(c.Executable) - } - return osext.Executable() -} - var ( system System systemRegistry []System diff --git a/service_go1.8.go b/service_go1.8.go new file mode 100644 index 0000000..64bb0a9 --- /dev/null +++ b/service_go1.8.go @@ -0,0 +1,15 @@ +//+build go1.8 + +package service + +import ( + "os" + "path/filepath" +) + +func (c *Config) execPath() (string, error) { + if len(c.Executable) != 0 { + return filepath.Abs(c.Executable) + } + return os.Executable() +}