Julien Laffaye b9f3ade291 Merge branch 'master' of github.com:jlaffaye/ftp | 4 years ago | |
---|---|---|
.github | 4 years ago | |
.travis.yml | 5 years ago | |
LICENSE | 12 years ago | |
README.md | 4 years ago | |
client_test.go | 4 years ago | |
conn_test.go | 4 years ago | |
debug.go | 5 years ago | |
ftp.go | 4 years ago | |
go.mod | 5 years ago | |
go.sum | 5 years ago | |
parse.go | 5 years ago | |
parse_test.go | 5 years ago | |
scanner.go | 7 years ago | |
scanner_test.go | 7 years ago | |
status.go | 4 years ago | |
status_test.go | 5 years ago | |
walker.go | 4 years ago | |
walker_test.go | 5 years ago |
A FTP client package for Go
go get -u github.com/jlaffaye/ftp
c, err := ftp.Dial("ftp.example.org:21", ftp.DialWithTimeout(5*time.Second))
if err != nil {
log.Fatal(err)
}
err = c.Login("anonymous", "anonymous")
if err != nil {
log.Fatal(err)
}
// Do something with the FTP conn
if err := c.Quit(); err != nil {
log.Fatal(err)
}
data := bytes.NewBufferString("Hello World")
err = c.Stor("test-file.txt", data)
if err != nil {
panic(err)
}
r, err := c.Retr("test-file.txt")
if err != nil {
panic(err)
}
defer r.Close()
buf, err := ioutil.ReadAll(r)
println(string(buf))