# README
goftp
A FTP client package for Go
Install
go get -u github.com/jlaffaye/ftp
Documentation
https://pkg.go.dev/github.com/jlaffaye/ftp
Example
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)
}
Store a file example
data := bytes.NewBufferString("Hello World")
err = c.Stor("test-file.txt", data)
if err != nil {
panic(err)
}
Read a file example
r, err := c.Retr("test-file.txt")
if err != nil {
panic(err)
}
defer r.Close()
buf, err := ioutil.ReadAll(r)
println(string(buf))
# Functions
Connect is an alias to Dial, for backward compatibility
Deprecated: Use [Dial] instead.
Dial connects to the specified address with optional options.
DialTimeout initializes the connection to the specified ftp server address.
DialWithContext returns a DialOption that configures the ServerConn with specified context The context will be used for the initial connection setup.
DialWithDebugOutput returns a DialOption that configures the ServerConn to write to the Writer everything it reads from the server.
DialWithDialer returns a DialOption that configures the ServerConn with specified net.Dialer.
DialWithDialFunc returns a DialOption that configures the ServerConn to use the specified function to establish both control and data connections
If used together with the DialWithNetConn option, the DialWithNetConn takes precedence for the control connection, while data connections will be established using function specified with the DialWithDialFunc option.
DialWithDisabledEPSV returns a DialOption that configures the ServerConn with EPSV disabled Note that EPSV is only used when advertised in the server features.
DialWithDisabledMLSD returns a DialOption that configures the ServerConn with MLSD option disabled
This is useful for servers which advertise MLSD (eg some versions of Serv-U) but don't support it properly.
DialWithDisabledUTF8 returns a DialOption that configures the ServerConn with UTF8 option disabled.
DialWithExplicitTLS returns a DialOption that configures the ServerConn to be upgraded to TLS See DialWithTLS for general TLS documentation.
DialWithForceListHidden returns a DialOption making ServerConn use LIST -a to include hidden files and folders in directory listings
This is useful for servers that do not do this by default, but it forces the use of the LIST command even if the server supports MLST.
DialWithLocation returns a DialOption that configures the ServerConn with specified time.Location The location is used to parse the dates sent by the server which are in server's timezone.
DialWithNetConn returns a DialOption that configures the ServerConn with the underlying net.Conn
Deprecated: Use [DialWithDialFunc] instead.
DialWithShutTimeout returns a DialOption that configures the ServerConn with maximum time to wait for the data closing status on control connection and nudging the control connection deadline before reading status.
DialWithTimeout returns a DialOption that configures the ServerConn with specified timeout.
DialWithTLS returns a DialOption that configures the ServerConn with specified TLS config
If called together with the DialWithDialFunc option, the DialWithDialFunc function will be used when dialing new connections but regardless of the function, the connection will be treated as a TLS connection.
DialWithWritingMDTM returns a DialOption making ServerConn use MDTM to set file time
This option addresses a quirk in the VsFtpd server which doesn't support the MFMT command for setting file time like other servers but by default uses the MDTM command with non-standard arguments for that.
StatusText returns a text for the FTP status code.
# Constants
30 seconds was chosen as it's the same duration as http.DefaultTransport's timeout.
The differents types of an Entry.
The differents types of an Entry.
The differents types of an Entry.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
FTP status codes, defined in RFC 959.
The different transfer types.
The different transfer types.
# Structs
DialOption represents an option to start a new connection with Dial.
Entry describes a file and is returned by List().
Response represents a data-connection.
ServerConn represents the connection to a remote FTP server.
Walker traverses the directory tree of a remote FTP server.
# Type aliases
EntryType describes the different types of an Entry.
TransferType denotes the formats for transferring Entries.