Skip to content

Commit cab5df0

Browse files
committed
Fix staticcheck error ST1005
staticcheck ./... error strings should not be capitalized error strings should not end with punctuation or newlines
1 parent 7bdac3e commit cab5df0

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

bufconn/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (c *HttpConn) Bond(m, h, p string, b []byte) (err error) {
4242
_, err = c.R.Discard(c.R.Buffered())
4343
return
4444
}
45-
err = errors.New("no available http proxy server")
45+
err = errors.New("[http] no available proxy server")
4646
}
4747
}
4848
return err

bufconn/socks4a.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func (c *Socks4aConn) bondData(m, h, p string) ([]byte, error) {
1919
switch strings.ToUpper(m) {
2020
case "CONNECT":
2121
default:
22-
return nil, errors.New("unsupported method: " + m)
22+
return nil, errors.New("[socks4a] unsupported method: " + m)
2323
}
2424

2525
pp, err := socks.ToPacketPort(p)
@@ -28,7 +28,7 @@ func (c *Socks4aConn) bondData(m, h, p string) ([]byte, error) {
2828
}
2929
l := len(h)
3030
if l > 256 {
31-
return nil, errors.New("too long hostname: " + h)
31+
return nil, errors.New("[socks4a] too long hostname: " + h)
3232
}
3333
data := []byte{4, 1}
3434
data = append(data, pp...)
@@ -54,7 +54,7 @@ func (c *Socks4aConn) Bond(m, h, p string, b []byte) (err error) {
5454
if b[1] == 0x5a {
5555
return nil
5656
}
57-
err = errors.New("CONNECT failed")
57+
err = errors.New("[socks4a] CONNECT failed")
5858
}
5959
}
6060
return err

bufconn/socks5.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (c *Socks5Conn) authorize() (err error) {
2323
var p socks.Packet
2424
p, err = ReceiveData(c.R)
2525
if err == nil && p[1] != 0 {
26-
err = errors.New("Authorization failed")
26+
err = errors.New("[socks5] authorization failed")
2727
}
2828
return
2929
}
@@ -32,7 +32,7 @@ func (c *Socks5Conn) bondData(m, h, p string) ([]byte, error) {
3232
switch strings.ToUpper(m) {
3333
case "CONNECT":
3434
default:
35-
return nil, errors.New("unsupported method: " + m)
35+
return nil, errors.New("[socks5] unsupported method: " + m)
3636
}
3737

3838
pp, err := socks.ToPacketPort(p)
@@ -41,7 +41,7 @@ func (c *Socks5Conn) bondData(m, h, p string) ([]byte, error) {
4141
}
4242
l := len(h)
4343
if l > 256 {
44-
return nil, errors.New("too long hostname: " + h)
44+
return nil, errors.New("[socks5] too long hostname: " + h)
4545
}
4646
data := []byte{5, 1, 0, 3}
4747
data = append(data, byte(l))
@@ -67,7 +67,7 @@ func (c *Socks5Conn) Bond(m, h, p string, b []byte) (err error) {
6767
if b[1] == 0 {
6868
return nil
6969
}
70-
err = errors.New("CONNECT failed")
70+
err = errors.New("[socks5] CONNECT failed")
7171
}
7272
}
7373
}

checker/checker.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@ func NewTargetChecker(u *url.URL, d time.Duration, c *bufconn.Conn, p *url.URL)
9191

9292
func New(s string, d time.Duration, p string) (*TargetChecker, error) {
9393
if len(s) == 0 {
94-
return nil, errors.New("[TargetChecker] server URL is empty.")
94+
return nil, errors.New("[TargetChecker] server URL is empty")
9595
}
9696
u, err := url.Parse(s)
9797
if err != nil {
98-
return nil, errors.New("[TargetChecker] server URL is invalid.")
98+
return nil, errors.New("[TargetChecker] server URL is invalid")
9999
}
100100
var pu *url.URL
101101
if len(p) > 0 {
102102
pu, err = url.Parse(p)
103103
}
104104
if err != nil {
105-
return nil, errors.New("[TargetChecker] proxy URL is invalid.")
105+
return nil, errors.New("[TargetChecker] proxy URL is invalid")
106106
}
107107
return NewTargetChecker(u, d, nil, pu), nil
108108
}

dispatcher/dispatcher.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func (d *Dispatcher) DispatchIP() (*bufconn.Conn, error) {
214214
func (d *Dispatcher) DispatchProxy() (cs bufconn.ConnSolver, proxy proxypool.Proxy, err error) {
215215
ProxyPool := GlobalProxyPool[d.ServerType]
216216
if ProxyPool == nil {
217-
err = errors.New("No valid proxy.")
217+
err = errors.New("no valid proxy")
218218
return
219219
}
220220
proxy = ProxyPool.GetProxy(d.proxyTried)
@@ -233,10 +233,10 @@ func (d *Dispatcher) DispatchProxy() (cs bufconn.ConnSolver, proxy proxypool.Pro
233233
c := cs.GetConn()
234234
_ = c.SetDeadline(time.Now())
235235
c.Close()
236-
err = errors.New("Proxy authentication is not implemented.")
236+
err = errors.New("proxy authentication is not implemented")
237237
}
238238
} else {
239-
err = errors.New("No valid proxy.")
239+
err = errors.New("no valid proxy")
240240
}
241241
return
242242
}

0 commit comments

Comments
 (0)