Golang upload via FTP and get FTP progress at the same time

I used http://github.com/dutchcoders/goftp to upload the file via FTP. It works fine, but when I want to download a file and get information about it (at the same time), it does not work!

fileName := "sth"
var err error
var ftp *goftp.FTP

if ftp, err = goftp.Connect("serverip:port"); err != nil {
    fmt.Println(err)
}

defer ftp.Close()

config := tls.Config{
    InsecureSkipVerify: true,
    ClientAuth:         tls.RequestClientCert,
}

if err = ftp.AuthTLS(config); err != nil {
    //      log.Println("1", err)
}

if err = ftp.Login("userName", "pass"); err != nil {
    log.Println("2", err)
}
//
if err = ftp.Cwd("/home/myDir/"); err != nil {
    log.Println("3", err)
}

var file *os.File
if file, err = os.Open(fileName); err != nil {
    log.Println("6", err)
}
defer file.Close()

fmt.Println("start")

go func() {
    fmt.Println("first")
    nmp := ftp.Stor(fileName, file)
    if nmp != nil {
        log.Println("7", err)
    } else {
        fmt.Println("first is runung")

    }
}()

go func() {
    fmt.Println("second")
    for {
        files, nms := ftp.List(fileName)
        if nms == nil {
            fmt.Println(files)
        }
        time.Sleep(1 * time.Second)
    }
}()

fmt.Println("end")

var mnmn string
fmt.Scan(&mnmn)

ftp.Stor func does not start, and my code returns below the outputs:

start
end
first
second
2016/05/31 13:21:38 7 <nil>
[]
[]
+4
source share
1 answer

goroutine ftp- (var ftp * goftp.FTP ), , . . . , . . . Solutons:

  • ftp goroutine

    var ftp,ftp1 *goftp.FTP
    

  • * goftp stor go. . .
+1

All Articles