Created
May 30, 2016 05:48
-
-
Save bergwolf/401a9408b94b6a4977543da0bf72f856 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/tls" | |
"fmt" | |
"github.com/bergwolf/goftp" | |
) | |
func main() { | |
var err error | |
var ftp *goftp.FTP | |
// For debug messages: goftp.ConnectDbg("ftp.server.com:21") | |
if ftp, err = goftp.Connect("192.168.80.211:21"); err != nil { | |
panic(err) | |
} | |
defer ftp.Close() | |
config := tls.Config{ | |
InsecureSkipVerify: true, | |
ClientAuth: tls.RequestClientCert, | |
} | |
if err = ftp.AuthTLS(config); err != nil { | |
panic(err) | |
} | |
if err = ftp.Login("username", "password"); err != nil { | |
panic(err) | |
} | |
if err = ftp.Cwd("/tmp/"); err != nil { | |
panic(err) | |
} | |
var curpath string | |
if curpath, err = ftp.Pwd(); err != nil { | |
panic(err) | |
} | |
fmt.Printf("Current path: %s", curpath) | |
var files []string | |
if files, err = ftp.List(""); err != nil { | |
panic(err) | |
} | |
fmt.Println(files) | |
if err = ftp.Upload("."); err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment