This repository contains a simple implementation of an FTP server and client in Go. The server allows clients to connect, request files, and retrieve a list of files from the server's directory. The client can connect to the server, download files, and retrieve a list of files from the server.
-
Server:
- Listens for incoming connections from clients.
- Supports file download requests.
- Provides a list of files in the server's directory.
-
Client:
- Connects to the server using TCP.
- Requests file downloads from the server.
- Retrieves a list of files from the server's directory.
go get github.com/jrjaro18/go-ftp
import "github.com/jrjaro18/go-ftp"
const (
addr = "path to your folder"
//NOTE: without / in the end
networkAddr = "localhost"
port = "20"
)
err := server.Start(addr, networkAddr, port)
if err != nil {
fmt.Println(err)
}
err := client.ReceiveFile(addr, fileName, networkAddr, port)
if err != nil {
fmt.Println(err)
}
To start the FTP client and receive the list of files available in server, use the following code snippet:
arr, err := client.ReceiveList(networkAddr, port)
if err != nil {
fmt.Println(err)
}