Sample code for 30+ languages & platforms
Go Requires Chilkat v11.0.0+

Transition from SFtp.ReadDir to SFtp.ReadDirListing

Provides instructions for replacing deprecated ReadDir method calls with ReadDirListing.

Chilkat Go Downloads

Go
    success := false

    sftp := chilkat.NewSFtp()

    //  ...
    //  ...

    handle := sftp.OpenDir(".")
    //  ...
    //  ...

    //  ------------------------------------------------------------------------
    //  The ReadDir method is deprecated:

    dirObj := sftp.ReadDir(*handle)
    if sftp.LastMethodSuccess() == false {
        fmt.Println(sftp.LastErrorText())
        sftp.DisposeSFtp()
        return
    }

    //  ...
    //  ...

    dirObj.DisposeSFtpDir()

    //  ------------------------------------------------------------------------
    //  Do the equivalent using ReadDirListing.
    //  Your application creates a new, empty SFtpDir object which is passed 
    //  in the last argument and filled upon success.

    dirOut := chilkat.NewSFtpDir()
    success = sftp.ReadDirListing(*handle,dirOut)
    if success == false {
        fmt.Println(sftp.LastErrorText())
        sftp.DisposeSFtp()
        dirOut.DisposeSFtpDir()
        return
    }

    //  ...
    //  ...

    sftp.CloseHandle(*handle)

    sftp.DisposeSFtp()
    dirOut.DisposeSFtpDir()