Skip to content

Commit

Permalink
Merge pull request #27 from lidashuang/develop
Browse files Browse the repository at this point in the history
fmt.Errorf() replace errors.New() and fmt.Sprintf()
  • Loading branch information
cyfdecyf committed Mar 12, 2014
2 parents f4a6080 + 5998d5b commit 81669bf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/shadowsocks-server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func getRequest(conn *ss.Conn) (host string, extra []byte, err error) {
case typeDm:
reqLen = int(buf[idDmLen]) + lenDmBase
default:
err = errors.New(fmt.Sprintf("addr type %d not supported", buf[idType]))
err = fmt.Errorf("addr type %d not supported", buf[idType])
return
}

Expand Down
7 changes: 2 additions & 5 deletions shadowsocks/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package shadowsocks

import (
"encoding/binary"
"errors"
"fmt"
"io"
"net"
Expand All @@ -21,13 +20,11 @@ func NewConn(cn net.Conn, cipher *Cipher) *Conn {
func RawAddr(addr string) (buf []byte, err error) {
host, portStr, err := net.SplitHostPort(addr)
if err != nil {
return nil, errors.New(
fmt.Sprintf("shadowsocks: address error %s %v", addr, err))
return nil, fmt.Errorf("shadowsocks: address error %s %v", addr, err)
}
port, err := strconv.Atoi(portStr)
if err != nil {
return nil, errors.New(
fmt.Sprintf("shadowsocks: invalid port %s", addr))
return nil, fmt.Errorf("shadowsocks: invalid port %s", addr)
}

hostLen := len(host)
Expand Down

0 comments on commit 81669bf

Please sign in to comment.