Skip to content

doroginin/ftp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 

Repository files navigation

FTP client for Go(lang)

install

go get github.com/smallfish/ftp

example

package main

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

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()                                                                  
}

About

FTP Client For Go(lang)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%