From 1147999aaa97954f8536fd653c4fd9af68c9d645 Mon Sep 17 00:00:00 2001 From: lingen <*\(^_^)/*> Date: Sat, 7 Jan 2023 14:42:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B6=E5=8F=91=E4=B8=8A=E4=BC=A0=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ssh/index.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ssh/index.go b/ssh/index.go index 0e5dd56..9de0f88 100644 --- a/ssh/index.go +++ b/ssh/index.go @@ -10,8 +10,6 @@ import ( "sync" . "github.com/MrYZhou/outil/common" - // . "o/common" - . "github.com/MrYZhou/outil/file" "github.com/pkg/sftp" "golang.org/x/crypto/ssh" @@ -274,10 +272,16 @@ func (c *Cli) UploadDir(base string, target string) { c.SftpClient.MkdirAll(targetPath) } // 创建远程文件 - for _, f := range list { + var wg sync.WaitGroup + for i, f := range list { targetPath := strings.Replace(f, base, target, 1) - c.UploadFile(f, targetPath) + wg.Add(1) + go func(i int,f string,targetPath string) { + c.UploadFile(f, targetPath) + wg.Done() + }(i,f,targetPath) } + wg.Wait() } /*