commit f10bc8ebf7494c38a0c361ed7927a26da04e5f28 from: Alexander Arkhipov date: Wed Feb 7 14:18:11 2024 UTC initial import commit - /dev/null commit + f10bc8ebf7494c38a0c361ed7927a26da04e5f28 blob - /dev/null blob + a427e38573da7a561091aa03d412d65a86054cad (mode 644) --- /dev/null +++ README @@ -0,0 +1,11 @@ +goget is yet another tool like wget, ftp, or curl, written in Go with +two goals in mind: + +- support parallel downloads +- support as many protocols as possible + +At the moment, the utility doesn't actually do much. You can compile it +with `go build .', and then download files over http like so: + + ./goget -p $number_of_parallels example.com \ + http://example.com/file1 https://examlpe.com/file2 blob - /dev/null blob + 7028a732a4b77cea43b6332e24b95366088239a0 (mode 644) --- /dev/null +++ go.mod @@ -0,0 +1,3 @@ +module git.manpager.org/goget + +go 1.21.6 blob - /dev/null blob + c2759cffd6e461432332fd18bc96dab7b5386703 (mode 644) --- /dev/null +++ goget.go @@ -0,0 +1,195 @@ +// Copyright (c) 2024 Alexander Arkhipov +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +package main + +import ( + "bufio" + "errors" + "flag" + "fmt" + "io" + "io/fs" + "net/http" + "os" + "strings" +) + +var qflag = flag.Bool("q", false, "be quiet") +var pflag = flag.Int("p", 1, "number of parallel downloads") + +type filename struct { + n int // how many times the url has been accessed + name string // end-file name + tmpfiles []