@@ -36,6 +36,10 @@ func newGetCmd(ctx context.Context) (cmd *cobra.Command) {
36
36
"If you accept preRelease as the binary asset from GitHub" )
37
37
flags .BoolVarP (& opt .AcceptPreRelease , "pre" , "" , false ,
38
38
"Same with option --accept-preRelease" )
39
+ flags .StringVarP (& opt .ProxyGitHub , "proxy-github" , "" , "" ,
40
+ `The proxy address of github.com, the proxy address will be the prefix of the final address.
41
+ Available proxy: gh.api.99988866.xyz
42
+ Thanks to https://github.com/hunshcn/gh-proxy` )
39
43
40
44
flags .IntVarP (& opt .Timeout , "time" , "" , 10 ,
41
45
`The default timeout in seconds with the HTTP request` )
@@ -52,6 +56,8 @@ func newGetCmd(ctx context.Context) (cmd *cobra.Command) {
52
56
flags .StringVarP (& opt .Arch , "arch" , "" , runtime .GOARCH , "The arch of target binary file" )
53
57
flags .BoolVarP (& opt .PrintSchema , "print-schema" , "" , false ,
54
58
"Print the schema of HDConfig if the flag is true without other function" )
59
+
60
+ _ = cmd .RegisterFlagCompletionFunc ("proxy-github" , ArrayCompletion ("gh.api.99988866.xyz" ))
55
61
return
56
62
}
57
63
@@ -64,6 +70,7 @@ type downloadOption struct {
64
70
MaxAttempts int
65
71
AcceptPreRelease bool
66
72
RoundTripper http.RoundTripper
73
+ ProxyGitHub string
67
74
68
75
ContinueAt int64
69
76
@@ -119,6 +126,10 @@ func (o *downloadOption) preRunE(cmd *cobra.Command, args []string) (err error)
119
126
}
120
127
o .URL = targetURL
121
128
129
+ if o .ProxyGitHub != "" {
130
+ o .URL = strings .Replace (o .URL , "github.com" , fmt .Sprintf ("%s/github.com" , o .ProxyGitHub ), 1 )
131
+ }
132
+
122
133
if o .Output == "" {
123
134
var urlObj * url.URL
124
135
if urlObj , err = url .Parse (o .URL ); err == nil {
0 commit comments