Home  >  Article  >  Backend Development  >  Connect to FTPS server using Golang

Connect to FTPS server using Golang

王林
王林forward
2024-02-13 20:48:09448browse

Connect to FTPS server using Golang

php editor Xigua today introduces how to use Golang to connect to the FTPS server. Golang is a fast and efficient programming language, while FTPS is a secure file transfer protocol. By combining the two, we can achieve safe and reliable file transfer. This article will introduce in detail the steps and precautions for connecting Golang to the FTPS server to help readers get started quickly and successfully complete the file transfer task. Whether you are a beginner or an experienced developer, this article can provide you with useful guidance and practical experience. Let’s explore this fun and practical topic together!

Question content

I try to use the ftp package to establish a default ftps connection:

c, err := ftp.Dial("some_srv:some_port", ftp.DialWithTLS(nil))

if err != nil {
    log.Fatal(err)
}

and get the surprisingly self-explanatory error: Connection: Connection refused

The documentation is terrible, completely unclear, how to configure ftps, how to combine options (e.g. timeout tls=true). Any ideas? )

Workaround

I couldn't get jlaffaye/ftp to work but found a very old (9 years old) library github.com/webguerilla/ftps and it works like a charm:

ftps := new(ftps.FTPS)
ftps.TLSConfig.InsecureSkipVerify = true

err := ftps.Connect("some_host", 21)
if err != nil {
    panic(err)
}

The above is the detailed content of Connect to FTPS server using Golang. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete