FTP Client For Go(lang)
Go
Switch branches/tags
Nothing to show
Latest commit 6d094f0 Aug 1, 2016 @smallfish committed on GitHub Merge pull request #8 from jangler/master
Don't try to get FTP response if connection fails
Permalink
Failed to load latest commit information.
README.md Update README.md Jul 30, 2016
ftp.go Don't try to get FTP response if connection fails Aug 29, 2015

README.md

FTP client for Go(lang)

install

go get github.com/smallfish/ftp

example

package main

import (
	"fmt"
	"github.com/smallfish/ftp"
	"io/ioutil"
	"os"
)

func main() {
	ftp := new(ftp.FTP)
	// debug default false
	ftp.Debug = true
	ftp.Connect("localhost", 21)

	// login
	ftp.Login("anonymous", "")
	if ftp.Code == 530 {
		fmt.Println("error: login failure")
		os.Exit(-1)
	}

	// pwd
	ftp.Pwd()
	fmt.Println("code:", ftp.Code, ", message:", ftp.Message)

	// make dir
	ftp.Mkd("/path")
	ftp.Request("TYPE I")

	// stor file
	b, _ := ioutil.ReadFile("/path/a.txt")
	ftp.Stor("/path/a.txt", b)

	ftp.Quit()
}