go vet
This commit is contained in:
parent
430f26f726
commit
0e85ff190d
|
@ -91,7 +91,7 @@ func main() {
|
||||||
parser.Usage = "[OPTIONS] (magnet URI or .torrent file path)..."
|
parser.Usage = "[OPTIONS] (magnet URI or .torrent file path)..."
|
||||||
posArgs, err := parser.Parse()
|
posArgs, err := parser.Parse()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, "Download from the BitTorrent network.\n")
|
fmt.Fprintf(os.Stderr, "%s", "Download from the BitTorrent network.\n\n")
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,11 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/anacrolix/torrent/bencode"
|
|
||||||
"github.com/anacrolix/torrent/util"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/anacrolix/torrent/bencode"
|
||||||
|
"github.com/anacrolix/torrent/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testMarshalUnmarshalMsg(t *testing.T, m Msg, expected string) {
|
func testMarshalUnmarshalMsg(t *testing.T, m Msg, expected string) {
|
||||||
|
@ -71,7 +72,10 @@ func TestMarshalUnmarshalMsg(t *testing.T) {
|
||||||
R: &Return{
|
R: &Return{
|
||||||
ID: "\xeb\xff6isQ\xffJ\xec)ͺ\xab\xf2\xfb\xe3F|\xc2g",
|
ID: "\xeb\xff6isQ\xffJ\xec)ͺ\xab\xf2\xfb\xe3F|\xc2g",
|
||||||
},
|
},
|
||||||
IP: util.CompactPeer{net.IPv4(124, 168, 180, 8).To4(), 62844},
|
IP: util.CompactPeer{
|
||||||
|
IP: net.IPv4(124, 168, 180, 8).To4(),
|
||||||
|
Port: 62844,
|
||||||
|
},
|
||||||
}, "d2:ip6:|\xa8\xb4\b\xf5|1:rd2:id20:\xeb\xff6isQ\xffJ\xec)ͺ\xab\xf2\xfb\xe3F|\xc2ge1:t1:\x031:y1:re")
|
}, "d2:ip6:|\xa8\xb4\b\xf5|1:rd2:id20:\xeb\xff6isQ\xffJ\xec)ͺ\xab\xf2\xfb\xe3F|\xc2ge1:t1:\x031:y1:re")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,12 +92,12 @@ func (info *Info) writeFiles(w io.Writer, open func(fi FileInfo) (io.ReadCloser,
|
||||||
for _, fi := range info.UpvertedFiles() {
|
for _, fi := range info.UpvertedFiles() {
|
||||||
r, err := open(fi)
|
r, err := open(fi)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error opening %s: %s", fi, err)
|
return fmt.Errorf("error opening %v: %s", fi, err)
|
||||||
}
|
}
|
||||||
wn, err := io.CopyN(w, r, fi.Length)
|
wn, err := io.CopyN(w, r, fi.Length)
|
||||||
r.Close()
|
r.Close()
|
||||||
if wn != fi.Length || err != nil {
|
if wn != fi.Length || err != nil {
|
||||||
return fmt.Errorf("error hashing %s: %s", fi, err)
|
return fmt.Errorf("error hashing %v: %s", fi, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue