MCPcopy Index your code
hub / github.com/Kenshin/curl

github.com/Kenshin/curl @0.0.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.0.4 ↗ · + Follow
47 symbols 114 edges 6 files 21 documented · 45%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

curl - 使用 Go語言 編寫的 多任務下載器

Build Status Version Gowalker Godoc Gitter Slack Jianliao

curl 是使用 Go語言 編寫的 多任務下載器,可以下載:二進位( exe, jpg ),文本文件( txt, json )等多種格式。

Multi-download

文檔

English | 繁體中文

支持

  • Mac OS
  • Linux
  • Windows ( usage kernel32.dll and SetConsoleCursorPosition function )

安裝

go get -u github.com/Kenshin/curl

使用

import "github.com/Kenshin/curl"

入門指南

逐行讀取文本
// curl.Get
code, res, _ := curl.Get("http://npm.taobao.org/mirrors/node/latest/SHASUMS256.txt")
if code != 0 {
    return
}

// close
defer res.Body.Close()

// parse callback
processFunc := func(content string, line int) bool {
    fmt.Printf("line is %v, content is %v", line, content)
    return false
}

// read line
if err := ReadLine(res.Body, processFunc); err != nil && err != io.EOF {
    fmt.Println(err)
}

ReadLine

簡單(單任務)下載
newDL, err := curl.New("http://npm.taobao.org/mirrors/node/v0.10.26/node.exe")
fmt.Printf("curl.New return ld  is %v\n", newDL)
fmt.Printf("curl.New return err is %v\n", err)

Simple-download

多任務下載
// mode 1
ts := curl.Task{}
ts1 := ts.New("http://xxx.xxx.xxx/node/latest/node.exe", "node.exe")
ts2 := ts.New("http://xxx.xxx.xxx/node/v4.0.0/win-x64/node.exe", "node40.exe")
ts3 := ts.New("http://xxx.xxx.xxx/node/v4.1.0/win-x64/node.exe", "node41.exe")
ts4 := ts.New("http://xxx.xxx.xxx/node/v4.2.0/win-x64/node.exe", "node42.exe")
ts5 := ts.New("http://xxx.xxx.xxx/node/v4.3.0/win-x64/node41.exe", "node43.exe")
newDL, err := curl.New(ts1, ts2, ts3, ts4, ts5, ts6)

fmt.Printf("curl.New return ld  is %v\n", newDL)
fmt.Printf("curl.New return err is %v\n", err)

// mode 2
dl := curl.Download {
    ts.New("http://7x2xql.com1.z0.glb.clouddn.com/visualhunt.json"),
    ts.New("http://7x2xql.com1.z0.glb.clouddn.com/holiday/02073.jpg"),
    ts.New("http://7x2xql.com1.z0.glb.clouddn.com/holiday/0207.jpg"),
}
dl.AddTask(ts.New("http://npm.taobao.org/mirrors/node/latest/node.exe", "nodeeeeeeeeeeeeeeeeeeeeeeee.exe", os.TempDir()))
dl.AddTask(ts.New("http://npm.taobao.org/mirrors/node/v5.7.0/win-x64/node.exe", "node4.exe", os.TempDir()))
dl.AddTask(ts.New("https://www.google.com/intl/zh-CN/chrome/browser/?standalone=1&extra=devchannel&platform=win64", "ChromeSetup.zip", os.TempDir()))
newDL, err := curl.New(dl)

fmt.Printf("curl.New return ld  is %v\n", newDL)
fmt.Printf("curl.New return err is %v\n", err)

Multi-download

自定義下載進度條樣式

custom progress schematic

// npm like
curl.Options.Header = false
curl.Options.Footer = false
curl.Options.LeftEnd = ""
curl.Options.RightEnd = ""
curl.Options.Fill = "█"
curl.Options.Arrow = ""
curl.Options.Empty = "░"

newDL, err := New("http://npm.taobao.org/mirrors/node/v0.10.26/node.exe")

node.exe: 100% ███████████████████████████████████████░░░░░░░░ 4s

custom download progressbar

相關鏈接

更新日誌

  • 2016-03-10, Version 0.0.4 support:

    • Add multi download.
    • Add custom progress.
    • Rework curl.New function.
    • Adapter Go 1.6.
  • 2016-03-05, Version 0.0.3 support:

    • Add beautiful dowload print.
  • 2014-07-10, Version 0.0.2 support:

    • Adapter Go 1.3.
  • 2014-05-28, Version 0.0.1 support:

    • New
    • Get
    • Readline

授權

license-badge

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

New
called by 9
curl.go
Error
called by 7
curl.go
AddTask
called by 5
curl.go
progressbar
called by 4
curl_print.go
setConsoleCursorPosition
called by 3
curl_windows.go
Get
called by 3
curl.go
New
called by 3
curl.go
curMove
called by 3
curl.go

Shape

Function 33
Struct 6
Method 4
TypeAlias 3
FuncType 1

Languages

Go100%

Modules by API surface

curl_windows.go13 symbols
curl.go13 symbols
curl_util.go7 symbols
curl_test.go7 symbols
curl_print.go4 symbols
curl_others.go3 symbols

For agents

$ claude mcp add curl \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact