From ec11f4d3d361e85af5232d640eaaaf0430de7b6c Mon Sep 17 00:00:00 2001 From: Bai Yingjie Date: Sat, 25 Dec 2021 22:04:14 +0800 Subject: [PATCH] move common errors to common place --- daemon.go | 3 --- gshellos.go | 14 ++++++++++++++ http.go | 12 ------------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/daemon.go b/daemon.go index 6973991..b2c65a5 100644 --- a/daemon.go +++ b/daemon.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "io" - "net/url" "os" "os/exec" "runtime" @@ -419,8 +418,6 @@ func init() { as.RegisterType(cmdInfo{}) as.RegisterType(codeRepoAddr{}) as.RegisterType(getFileContent{}) - as.RegisterType((*url.Error)(nil)) - as.RegisterType((*exec.ExitError)(nil)) as.RegisterType(tryUpdate{}) as.RegisterType((*gshellBin)(nil)) } diff --git a/gshellos.go b/gshellos.go index cf256cf..ea4aa6f 100644 --- a/gshellos.go +++ b/gshellos.go @@ -5,10 +5,15 @@ import ( "encoding/hex" "errors" "io" + "net" + "net/url" "os" "os/exec" "strings" + "syscall" "time" + + as "github.com/godevsig/adaptiveservice" ) var ( @@ -106,3 +111,12 @@ func RunShCmd(cmd string) string { output, _ := exec.Command("sh", fields...).CombinedOutput() return string(output) } + +func init() { + as.RegisterType((*net.OpError)(nil)) + as.RegisterType((*net.TCPAddr)(nil)) + as.RegisterType((*os.SyscallError)(nil)) + as.RegisterType(syscall.Errno(0)) + as.RegisterType((*url.Error)(nil)) + as.RegisterType((*exec.ExitError)(nil)) +} diff --git a/http.go b/http.go index 344e65d..9d72561 100644 --- a/http.go +++ b/http.go @@ -5,12 +5,7 @@ package gshellos import ( "fmt" "io" - "net" "net/http" - "os" - "syscall" - - as "github.com/godevsig/adaptiveservice" ) func init() { @@ -34,10 +29,3 @@ func httpGetFunc(url string) ([]byte, error) { return body, nil } - -func init() { - as.RegisterType((*net.OpError)(nil)) - as.RegisterType((*net.TCPAddr)(nil)) - as.RegisterType((*os.SyscallError)(nil)) - as.RegisterType(syscall.Errno(0)) -}