@@ -36,6 +36,10 @@ func newGetCmd(ctx context.Context) (cmd *cobra.Command) {
3636 "If you accept preRelease as the binary asset from GitHub" )
3737 flags .BoolVarP (& opt .AcceptPreRelease , "pre" , "" , false ,
3838 "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` )
3943
4044 flags .IntVarP (& opt .Timeout , "time" , "" , 10 ,
4145 `The default timeout in seconds with the HTTP request` )
@@ -52,6 +56,8 @@ func newGetCmd(ctx context.Context) (cmd *cobra.Command) {
5256 flags .StringVarP (& opt .Arch , "arch" , "" , runtime .GOARCH , "The arch of target binary file" )
5357 flags .BoolVarP (& opt .PrintSchema , "print-schema" , "" , false ,
5458 "Print the schema of HDConfig if the flag is true without other function" )
59+
60+ _ = cmd .RegisterFlagCompletionFunc ("proxy-github" , ArrayCompletion ("gh.api.99988866.xyz" ))
5561 return
5662}
5763
@@ -64,6 +70,7 @@ type downloadOption struct {
6470 MaxAttempts int
6571 AcceptPreRelease bool
6672 RoundTripper http.RoundTripper
73+ ProxyGitHub string
6774
6875 ContinueAt int64
6976
@@ -119,6 +126,10 @@ func (o *downloadOption) preRunE(cmd *cobra.Command, args []string) (err error)
119126 }
120127 o .URL = targetURL
121128
129+ if o .ProxyGitHub != "" {
130+ o .URL = strings .Replace (o .URL , "github.com" , fmt .Sprintf ("%s/github.com" , o .ProxyGitHub ), 1 )
131+ }
132+
122133 if o .Output == "" {
123134 var urlObj * url.URL
124135 if urlObj , err = url .Parse (o .URL ); err == nil {
0 commit comments