File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # ## Example user template template
2- # ## Example user template
3-
41# IntelliJ project files
52.idea
63* .iml
74out
85gen
6+
97# ## Go template
108# Binaries for programs and plugins
119* .exe
Original file line number Diff line number Diff line change 1+ module gh
2+
3+ go 1.17
4+
5+ require github.com/creack/pty v1.1.17
Original file line number Diff line number Diff line change 1+ github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI =
2+ github.com/creack/pty v1.1.17 /go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4 =
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "fmt"
5+ "github.com/creack/pty"
6+ "io"
7+ "os"
8+ "os/exec"
9+ "runtime"
10+ "strings"
11+ )
12+
13+ func isWindows () bool {
14+ flag := runtime .GOOS == "windows"
15+ return flag
16+ }
17+
18+ func execCommand (cmd string ) {
19+ args := [2 ]string {
20+ "bash" , "-c" ,
21+ }
22+ if isWindows () {
23+ args [0 ] = "cmd"
24+ args [1 ] = "/C"
25+ }
26+ c := exec .Command (args [0 ], args [1 ], cmd )
27+ f , err := pty .Start (c )
28+ if err != nil {
29+ panic (err )
30+ }
31+ _ , err = io .Copy (os .Stdout , f )
32+ if err != nil {
33+ return
34+ }
35+ }
36+
37+ func githubProxy () {
38+ var cmds = os .Args [1 :]
39+ for i := 1 ; i < len (cmds ); i ++ {
40+ cmd := cmds [i ]
41+ if strings .Contains (cmd , "https://github.com" ) {
42+ cmds [i ] = strings .ReplaceAll (cmd , "https://github.com" , "https://ghproxy.com/https://github.com" )
43+ }
44+
45+ if strings .Contains (cmd , "https://raw.githubusercontent.com" ) {
46+ cmds [i ] = strings .ReplaceAll (cmd , "https://raw.githubusercontent.com" , "https://ghproxy.com/https://raw.githubusercontent.com" )
47+ }
48+
49+ if strings .Contains (cmd , "https://gist.github.com" ) {
50+ cmds [i ] = strings .ReplaceAll (cmd , "https://gist.github.com" , "https://ghproxy.com/https://gist.github.com" )
51+ }
52+ }
53+
54+ cmd := strings .Join (cmds , " " )
55+ fmt .Printf ("👉 : %v\n " , cmd )
56+ execCommand (cmd )
57+ }
58+
59+ func main () {
60+ githubProxy ()
61+ }
You can’t perform that action at this time.
0 commit comments