Selaa lähdekoodia

Replace DialWithOptions with Dial

No need for a dedicated function as Dial can take no options.
Julien Laffaye 6 vuotta sitten
vanhempi
commit
e6de3d35bf
3 muutettua tiedostoa jossa 6 lisäystä ja 11 poistoa
  1. 1 1
      README.md
  2. 1 1
      conn_test.go
  3. 4 9
      ftp.go

+ 1 - 1
README.md

@@ -16,7 +16,7 @@ go get -u github.com/jlaffaye/ftp
 ## Example ##
 
 ```go
-c, err := ftp.DialWithOptions("ftp.example.org:21", ftp.DialWithTimeout(5*time.Second))
+c, err := ftp.Dial("ftp.example.org:21", ftp.DialWithTimeout(5*time.Second))
 if err != nil {
     log.Fatal(err)
 }

+ 1 - 1
conn_test.go

@@ -292,7 +292,7 @@ func openConn(t *testing.T, addr string, options ...DialOption) (*ftpMock, *Serv
 	}
 	defer mock.Close()
 
-	c, err := DialWithOptions(mock.Addr(), options...)
+	c, err := Dial(mock.Addr(), options...)
 	if err != nil {
 		t.Fatal(err)
 	}

+ 4 - 9
ftp.go

@@ -40,7 +40,7 @@ type ServerConn struct {
 	mlstSupported bool
 }
 
-// DialOption represents an option to start a new connection with DialWithOptions
+// DialOption represents an option to start a new connection with Dial
 type DialOption struct {
 	setup func(do *dialOptions)
 }
@@ -71,8 +71,8 @@ type Response struct {
 	closed bool
 }
 
-// DialWithOptions connects to the specified address with optinal options
-func DialWithOptions(addr string, options ...DialOption) (*ServerConn, error) {
+// Dial connects to the specified address with optinal options
+func Dial(addr string, options ...DialOption) (*ServerConn, error) {
 	do := &dialOptions{}
 	for _, option := range options {
 		option.setup(do)
@@ -197,17 +197,12 @@ func Connect(addr string) (*ServerConn, error) {
 	return Dial(addr)
 }
 
-// Dial is like DialTimeout with no timeout
-func Dial(addr string) (*ServerConn, error) {
-	return DialTimeout(addr, 0)
-}
-
 // DialTimeout initializes the connection to the specified ftp server address.
 //
 // It is generally followed by a call to Login() as most FTP commands require
 // an authenticated user.
 func DialTimeout(addr string, timeout time.Duration) (*ServerConn, error) {
-	return DialWithOptions(addr, DialWithTimeout(timeout))
+	return Dial(addr, DialWithTimeout(timeout))
 }
 
 // Login authenticates the client with specified user and password.