Skip to content
This repository was archived by the owner on May 27, 2021. It is now read-only.

Repository files navigation

goftp

Build StatusCoverage StatusGo ReportCard

A FTP and FTPS client package for Go

Install

go get -u github.com/dchang-dchang/ftp

Usage

Create a FTP connection

host, port:="ftp.hostname.com", 21_=s.Dial(fmt.Sprintf("%s:%d", host, port))
defers.Quit()

Set timeouts, debug mode, and/or TLS config for implicit TLS

(Note: If a TLSConfig is set, both the command and data channel will be secured with the same config)

host, port:="ftp.hostname.com", 990s:= ftp.ServerConn{
Debug: true,
Timeout: 30*time.Second,
TLSConfig: &tls.Config{ServerName: host},
}
_=s.Dial(fmt.Sprintf("%s:%d", host, port))
defers.Quit()

Login

_=s.Login(username, password)

List files

entries, _:=s.List("/")
for_, entry:=rangeentries {
fmt.Println(entry)
}

Get a file

res, _:=s.Retr("/filename.txt")
reader:=bufio.NewReader(res)
for {
line, err:=reader.ReadString('\n')
iferr==io.EOF {
break
} elseiferr!=nil {
panic(err)
}
fmt.Println(line)
}

Documentation

http://godoc.org/github.com/dchang-dchang/ftp

About

FTP client package for Go

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages