Skip to content

Commit 4636633

Browse files
Merge pull request #143 from marten-seemann/fix-linters
fix go vet and staticcheck failures
2 parents d7d65e5 + 927b81c commit 4636633

File tree

2 files changed

+6
-32
lines changed

2 files changed

+6
-32
lines changed

codec.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -176,29 +176,3 @@ func sizeForAddr(p Protocol, b []byte) (skip, size int, err error) {
176176
return n, size, nil
177177
}
178178
}
179-
180-
func bytesSplit(b []byte) ([][]byte, error) {
181-
var ret [][]byte
182-
for len(b) > 0 {
183-
code, n, err := ReadVarintCode(b)
184-
if err != nil {
185-
return nil, err
186-
}
187-
188-
p := ProtocolWithCode(code)
189-
if p.Code == 0 {
190-
return nil, fmt.Errorf("no protocol with code %d", b[0])
191-
}
192-
193-
n2, size, err := sizeForAddr(p, b[n:])
194-
if err != nil {
195-
return nil, err
196-
}
197-
198-
length := n + n2 + size
199-
ret = append(ret, b[:length])
200-
b = b[length:]
201-
}
202-
203-
return ret, nil
204-
}

transcoders.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ var TranscoderOnion = NewTranscoderFromFunctions(onionStB, onionBtS, nil)
137137
func onionStB(s string) ([]byte, error) {
138138
addr := strings.Split(s, ":")
139139
if len(addr) != 2 {
140-
return nil, fmt.Errorf("failed to parse onion addr: %s does not contain a port number.", s)
140+
return nil, fmt.Errorf("failed to parse onion addr: %s does not contain a port number", s)
141141
}
142142

143143
// onion address without the ".onion" substring
144144
if len(addr[0]) != 16 {
145-
return nil, fmt.Errorf("failed to parse onion addr: %s not a Tor onion address.", s)
145+
return nil, fmt.Errorf("failed to parse onion addr: %s not a Tor onion address", s)
146146
}
147147
onionHostBytes, err := base32.StdEncoding.DecodeString(strings.ToUpper(addr[0]))
148148
if err != nil {
@@ -180,7 +180,7 @@ var TranscoderOnion3 = NewTranscoderFromFunctions(onion3StB, onion3BtS, nil)
180180
func onion3StB(s string) ([]byte, error) {
181181
addr := strings.Split(s, ":")
182182
if len(addr) != 2 {
183-
return nil, fmt.Errorf("failed to parse onion addr: %s does not contain a port number.", s)
183+
return nil, fmt.Errorf("failed to parse onion addr: %s does not contain a port number", s)
184184
}
185185

186186
// onion address without the ".onion" substring
@@ -228,7 +228,7 @@ func garlic64StB(s string) ([]byte, error) {
228228
// i2p base64 address will be between 516 and 616 characters long, depending on
229229
// certificate type
230230
if len(s) < 516 || len(s) > 616 {
231-
return nil, fmt.Errorf("failed to parse garlic addr: %s not an i2p base64 address. len: %d\n", s, len(s))
231+
return nil, fmt.Errorf("failed to parse garlic addr: %s not an i2p base64 address. len: %d", s, len(s))
232232
}
233233
garlicHostBytes, err := garlicBase64Encoding.DecodeString(s)
234234
if err != nil {
@@ -249,7 +249,7 @@ func garlic64BtS(b []byte) (string, error) {
249249
func garlic64Validate(b []byte) error {
250250
// A garlic64 address will always be greater than 386 bytes long when encoded.
251251
if len(b) < 386 {
252-
return fmt.Errorf("failed to validate garlic addr: %s not an i2p base64 address. len: %d\n", b, len(b))
252+
return fmt.Errorf("failed to validate garlic addr: %s not an i2p base64 address. len: %d", b, len(b))
253253
}
254254
return nil
255255
}
@@ -286,7 +286,7 @@ func garlic32Validate(b []byte) error {
286286
// an i2p base64 for an Encrypted Leaseset v2 will be at least 35 bytes
287287
// long other than that, they will be exactly 32 bytes
288288
if len(b) < 35 && len(b) != 32 {
289-
return fmt.Errorf("failed to validate garlic addr: %s not an i2p base32 address. len: %d\n", b, len(b))
289+
return fmt.Errorf("failed to validate garlic addr: %s not an i2p base32 address. len: %d", b, len(b))
290290
}
291291
return nil
292292
}

0 commit comments

Comments
 (0)