Skip to content

Build passing #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e3af4bc
Update http.go
abzcoding Aug 19, 2020
144e418
Update main.go
abzcoding Aug 19, 2020
8575ef8
Update http.go
abzcoding Aug 19, 2020
64314c8
Update http.go
abzcoding Aug 19, 2020
4eea90b
Update http.go
abzcoding Aug 19, 2020
9accef4
Update main.go
abzcoding Aug 19, 2020
37964d7
Update http.go
abzcoding Aug 19, 2020
2a1c3d6
Update http.go
abzcoding Aug 19, 2020
1115cd8
Update http.go
abzcoding Aug 19, 2020
7fb70cd
Update README.md
abzcoding Aug 19, 2020
0d1561a
Merge pull request #1 from abzcoding/socks5-proxy
abzcoding Aug 19, 2020
5ed3d64
Update README.md
abzcoding Aug 19, 2020
81d344f
Update README.md
abzcoding Aug 19, 2020
bcc3af9
Update README.md
abzcoding Aug 19, 2020
24607c6
Update README.md
abzcoding Aug 19, 2020
f0a12d8
Update http.go
abzcoding Aug 19, 2020
756bfcb
Update http_test.go
abzcoding Aug 19, 2020
b42e4fa
Update joiner.go
abzcoding Aug 19, 2020
089aeb7
Update main.go
abzcoding Aug 19, 2020
fe6883d
Update state.go
abzcoding Aug 19, 2020
75d2ad7
Merge pull request #3 from abzcoding/performance
abzcoding Aug 19, 2020
327fc8b
Update Makefile
abzcoding Aug 30, 2020
b5c791b
Update main.go
abzcoding Aug 30, 2020
4dcdf00
Merge pull request #4 from abzcoding/file-list
abzcoding Aug 30, 2020
69c59b2
Update README.md
abzcoding Aug 30, 2020
44e2abc
Update README.md
abzcoding Aug 30, 2020
9aade6b
added bandwidth limiting to hget
Sep 10, 2020
5d3852b
Merge pull request #5 from abzcoding/bw-limit
abzcoding Sep 10, 2020
326db66
Update README.md
abzcoding Sep 10, 2020
0208775
Update .travis.yml
abzcoding Sep 10, 2020
dd774a7
Update README.md
abzcoding Sep 10, 2020
ceb836b
fixed build issue
abzcoding Jun 15, 2021
fae557f
Update README.md
abzcoding Jun 21, 2021
7d0c6fb
Update README.md
abzcoding Jun 21, 2021
c22b586
Update README.md
abzcoding Jun 21, 2021
264c222
removed unused returns
abzcoding Jun 21, 2021
c2f9688
cleaned up the code a bit
abzcoding Jun 21, 2021
f94c9e3
cleaned up the code a bit
abzcoding Jun 21, 2021
f6e4d04
cleaned up the code a bit
abzcoding Jun 21, 2021
7953a7a
Update README.md
abzcoding Jun 21, 2021
ff8e088
Update README.md
abzcoding Dec 27, 2021
99cd40a
adding resume capability
abzcoding Feb 10, 2025
a0cd9f9
update readme
abzcoding Feb 10, 2025
18f1800
clean up the code a bit
abzcoding Feb 10, 2025
a40d109
refactor: update URL parsing and file extraction logic
Mar 21, 2025
103794d
feat: dry
abzcoding Mar 21, 2025
614694c
Merge pull request #6 from belingud/master
abzcoding Mar 21, 2025
6901ee3
feat: code cleanup + resume bug fix
abzcoding Mar 21, 2025
bc8c96a
Update README.md
abzcoding Mar 21, 2025
1153b76
use newer golang in travis ci
abzcoding Mar 21, 2025
cd16414
feat: migrating from travis to github actions
abzcoding Mar 21, 2025
d83eeb4
using goreleaser
abzcoding Mar 21, 2025
7ecb3ae
newer upload artifact
abzcoding Mar 21, 2025
1dc7d24
fix: minor issues
abzcoding Mar 21, 2025
52dc693
fully removing travis
abzcoding Mar 21, 2025
dab326b
feat: add some test cases and upgrade go version
abzcoding Mar 23, 2025
3885ff5
fix: go version
abzcoding Mar 23, 2025
a2eed9e
fix zizmor issues
abzcoding Mar 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions: {}

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false


- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24'

- name: Go Cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Security Scan
uses: securego/gosec@master
with:
args: '-exclude=G304,G306,G104 ./...'

- name: Build
run: go build -v -ldflags "-X main.GitCommit=$(git describe --always)" -o bin/hget

- name: Test
run: go test -v ./...

- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: hget
path: bin/hget
if-no-files-found: error
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on:
push:
tags:
- 'v*'
permissions: {}

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24'
cache: false

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40 changes: 40 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
ignore:
- goos: windows
goarch: arm64
ldflags:
- -s -w -X main.GitCommit={{.ShortCommit}}
archives:
- format: tar.gz
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

38 changes: 25 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
COMMIT = $$(git describe --always)
COMMIT := $(shell git describe --always)
BINARY := hget
BINDIR := bin
INSTALL_PATH := /usr/local/bin

.PHONY: all clean build install test deps

all: build

deps:
@echo "====> Install dependencies..."
go get -d github.com/fatih/color
go get -d github.com/mattn/go-colorable
go get -d github.com/mattn/go-isatty
go get -d github.com/fatih/color
go get -d gopkg.in/cheggaaa/pb.v1
go get -d github.com/mattn/go-isatty
@echo "====> Updating dependencies..."
go mod tidy

clean:
@echo "====> Remove installed binary"
rm -f bin/hget
@echo "====> Removing installed binary"
rm -f $(BINDIR)/$(BINARY)

test:
@echo "====> Running tests..."
go test -v ./...

build: deps
@echo "====> Building $(BINARY) in ./$(BINDIR)"
mkdir -p $(BINDIR)
go build -ldflags "-X main.GitCommit=\"$(COMMIT)\"" -o $(BINDIR)/$(BINARY)

install: deps
@echo "====> Build hget in ./bin "
go build -ldflags "-X main.GitCommit=\"$(COMMIT)\"" -o bin/hget
install: build
@echo "====> Installing $(BINARY) in $(INSTALL_PATH)/$(BINARY)"
chmod +x ./$(BINDIR)/$(BINARY)
sudo mv ./$(BINDIR)/$(BINARY) $(INSTALL_PATH)/$(BINARY)
64 changes: 49 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,64 @@
# hget
This project is my personal project to learn golang to build something useful.
[![Build Status](https://github.com/abzcoding/hget/actions/workflows/build.yml/badge.svg)](https://github.com/abzcoding/hget/actions/workflows/build.yml)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/abzcoding/hget/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/abzcoding/hget/?branch=master)
[![Maintainability](https://api.codeclimate.com/v1/badges/936e2aacab5946478295/maintainability)](https://codeclimate.com/github/abzcoding/hget/maintainability)
[![Codebeat](https://codebeat.co/badges/ea357ae8-4d84-4599-bff7-cffc4f28fd67)](https://codebeat.co/projects/github-com-abzcoding-hget-master)

# hget
![](https://i.gyazo.com/641166ab79e196e35d1a0ef3f9befd80.png)

### Features
- Fast (multithreading & stuff)
- Ability to interrupt/resume (task mangement)
- Support for proxies( socks5 or http)
- Bandwidth limiting
- You can give it a file that contains list of urls to download

### Install

**Build Status**: [![Build Status](https://travis-ci.org/huydx/hget.svg?branch=master)](https://travis-ci.org/huydx/hget)

## Install

```
$ go get -d github.com/huydx/hget
$ cd $GOPATH/src/github.com/huydx/hget
```bash
$ go get github.com/abzcoding/hget
$ cd $GOPATH/src/github.com/abzcoding/hget
$ make clean install
```

Binary file will be built at ./bin/hget, you can copy to /usr/bin or /usr/local/bin and even `alias wget hget` to replace wget totally :P

## Usage
### Usage

```bash
hget [-n parallel] [-skip-tls false] [-rate bwRate] [-proxy proxy_server] [-file filename] [URL] # to download url, with n connections, and not skip tls certificate
hget - resume TaskName # to resume task
hget -proxy "127.0.0.1:12345" URL # to download using socks5 proxy
hget -proxy "http://sample-proxy.com:8080" URL # to download using http proxy
hget -file sample.txt # to download a list of urls
hget -n 4 -rate 100KB URL # to download using 4 threads & limited to 100KB per second

# real world example
hget -n 16 -rate 10MiB "https://old-releases.ubuntu.com/releases/22.04.1/ubuntu-22.04-beta-live-server-amd64.iso"
# resuming a stopped download
hget -resume "ubuntu-22.04-beta-live-server-amd64.iso"
```
hget [Url] [-n parallel] [-skip-tls false] //to download url, with n connections, and not skip tls certificate
hget tasks //get interrupted tasks
hget resume [TaskName | URL] //to resume task

### Cleanup

you might wanna cleanup `~/.hget` folder after downloading a lot of unfinished/cancelled downloads

### Help
```
[I] ➜ hget -h
Usage of hget:
-file string
path to a file that contains one URL per line
-n int
number of connections (default 12)
-proxy string
proxy for downloading, e.g. -proxy '127.0.0.1:12345' for socks5 or -proxy 'http://proxy.com:8080' for http proxy
-rate string
bandwidth limit during download, e.g. -rate 10kB or -rate 10MiB
-resume string
resume download task with given task name (or URL)
-skip-tls
skip certificate verification for https (default false)
```

To interrupt any on-downloading process, just ctrl-c or ctrl-d at the middle of the download, hget will safely save your data and you will be able to resume later
Expand All @@ -32,5 +68,3 @@ To interrupt any on-downloading process, just ctrl-c or ctrl-d at the middle of

### Resume
![](https://i.gyazo.com/caa69808f6377421cb2976f323768dc4.gif)


21 changes: 21 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module github.com/abzcoding/hget

go 1.24

require (
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b
github.com/fatih/color v1.18.0
github.com/fujiwara/shapeio v1.0.0
github.com/imkira/go-task v1.0.0
github.com/mattn/go-colorable v0.1.14
github.com/mattn/go-isatty v0.0.20
golang.org/x/net v0.37.0
gopkg.in/cheggaaa/pb.v1 v1.0.28
)

require (
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
golang.org/x/sys v0.31.0 // indirect
golang.org/x/time v0.10.0 // indirect
)
47 changes: 47 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b h1:mimo19zliBX/vSQ6PWWSL9lK8qwHozUj03+zLoEB8O0=
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b/go.mod h1:fvzegU4vN3H1qMT+8wDmzjAcDONcgo2/SZ/TyfdUOFs=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/fujiwara/shapeio v1.0.0 h1:xG5D9oNqCSUUbryZ/jQV3cqe1v2suEjwPIcEg1gKM8M=
github.com/fujiwara/shapeio v1.0.0/go.mod h1:LmEmu6L/8jetyj1oewewFb7bZCNRwE7wLCUNzDLaLVA=
github.com/imkira/go-task v1.0.0 h1:r8RN5nLcmVpYf/UB28d1w4XApVxDntWLAsiExNIptsY=
github.com/imkira/go-task v1.0.0/go.mod h1:xU9xcPxKeBOQTwx8ILmT8xLxrm/SFmyBhPO8SlCRyRI=
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.10.0 h1:3usCWA8tQn0L8+hFJQNgzpWbd89begxN66o1Ojdn5L4=
golang.org/x/time v0.10.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/cheggaaa/pb.v1 v1.0.28 h1:n1tBJnnK2r7g9OW2btFH91V92STTUevLXYFb8gy9EMk=
gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading