Skip to content

Commit 3998f06

Browse files
committed
Updated README.md
1 parent d974065 commit 3998f06

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

README.md

+50-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1-
# richkago
1+
# Richkago - GoLang Download Engine
22

3-
GoLang Download Engine
3+
#### Richka (From Ukrainian: Рiчка) means river, stands for the download speed of Richka Engine
4+
5+
#### This project is only active on GitHub (https://github.com/ghinknet/richkago), repositories on any other platform are mirror
6+
#### We will not process PRs or Issues outside of GitHub
7+
8+
#### Richka for python is here (https://github.com/ghinknet/richka)
9+
10+
## Usage
11+
12+
`import "github.com/ghinknet/richkago"` and run script in your code, for example:
13+
14+
```
15+
package main
16+
17+
import (
18+
"fmt"
19+
"github.com/ghinknet/richkago"
20+
"time"
21+
)
22+
23+
func main() {
24+
controller := richkago.NewController()
25+
26+
go func() {
27+
// Start download
28+
timeUsed, fileSize, err := richkago.Download("https://mirrors.tuna.tsinghua.edu.cn/raspberry-pi-os-images/raspios_lite_arm64/images/raspios_lite_arm64-2024-11-19/2024-11-19-raspios-bookworm-arm64-lite.img.xz", "2024-11-19-raspios-bookworm-arm64-lite3.img.xz", controller)
29+
if err != nil {
30+
fmt.Println("Download failed:", err)
31+
return
32+
}
33+
34+
// Print result
35+
fmt.Printf("Time used: %.2f seconds\n", timeUsed)
36+
fmt.Printf("Speed: %.2f MiB/s\n", float64(fileSize)/timeUsed/1024/1024)
37+
}()
38+
39+
// Monitor progress
40+
for controller.Status() != 0 && controller.Status() != -3 {
41+
if controller.Status() == 1 {
42+
fmt.Printf("Download Progress: %.2f%%\r", controller.Progress())
43+
}
44+
time.Sleep(100 * time.Millisecond)
45+
}
46+
if controller.Status() == 0 {
47+
fmt.Println("Download completed.")
48+
}
49+
}
50+
```
51+
Then you'll get a file from Internet :D.

0 commit comments

Comments
 (0)