From 571f1b95fecfca05e54b5bff29c1c004a18c13cd Mon Sep 17 00:00:00 2001 From: hupeh Date: Wed, 4 Sep 2024 18:41:20 +0800 Subject: [PATCH] =?UTF-8?q?WIP:=20=E7=BC=96=E5=86=99=20git=20=E5=92=8C=20g?= =?UTF-8?q?o=20=E7=9A=84=E7=9B=B8=E5=85=B3=E5=91=BD=E4=BB=A4=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- misc/chdir.go | 7 +++++++ misc/git_clone.go | 28 ++++++++++++++++++++++++++++ misc/git_pull.go | 14 ++++++++++++++ misc/git_reset.go | 14 ++++++++++++++ misc/go_build.go | 14 ++++++++++++++ misc/go_mod_tidy.go | 14 ++++++++++++++ misc/go_test.go | 14 ++++++++++++++ 7 files changed, 105 insertions(+) create mode 100644 misc/chdir.go create mode 100644 misc/git_clone.go create mode 100644 misc/git_pull.go create mode 100644 misc/git_reset.go create mode 100644 misc/go_build.go create mode 100644 misc/go_mod_tidy.go create mode 100644 misc/go_test.go diff --git a/misc/chdir.go b/misc/chdir.go new file mode 100644 index 0000000..59be27e --- /dev/null +++ b/misc/chdir.go @@ -0,0 +1,7 @@ +package misc + +import "os" + +func Chdir(codepath string) error { + return os.Chdir(codepath) +} diff --git a/misc/git_clone.go b/misc/git_clone.go new file mode 100644 index 0000000..79bfebb --- /dev/null +++ b/misc/git_clone.go @@ -0,0 +1,28 @@ +package misc + +import ( + "os" + "os/exec" +) + +func GitClone() error { + cmd := exec.Command("git", "clone", "https://github.com/HupeHup/hupe.git", "gittemp") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Stdin = os.Stdin + if err := cmd.Run(); err != nil { + return err + } + + cmd = exec.Command("mv", "gittemp/.git", ".") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + if err := cmd.Run(); err != nil { + return err + } + + cmd = exec.Command("rm", "-rf", "gittemp") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + return cmd.Run() +} diff --git a/misc/git_pull.go b/misc/git_pull.go new file mode 100644 index 0000000..d2df85c --- /dev/null +++ b/misc/git_pull.go @@ -0,0 +1,14 @@ +package misc + +import ( + "os" + "os/exec" +) + +func GitPull() error { + cmd := exec.Command("git", "pull") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Stdin = os.Stdin + return cmd.Run() +} diff --git a/misc/git_reset.go b/misc/git_reset.go new file mode 100644 index 0000000..b8e4507 --- /dev/null +++ b/misc/git_reset.go @@ -0,0 +1,14 @@ +package misc + +import ( + "os" + "os/exec" +) + +func GitRest() error { + cmd := exec.Command("git", "reset", "--hard", "origin/main") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Stdin = os.Stdin + return cmd.Run() +} diff --git a/misc/go_build.go b/misc/go_build.go new file mode 100644 index 0000000..3ea1866 --- /dev/null +++ b/misc/go_build.go @@ -0,0 +1,14 @@ +package misc + +import ( + "os" + "os/exec" +) + +func GoBuild() error { + cmd := exec.Command("go", "build", "-ldflags", "\"-w-s\"", "-trimpath", "path/to/main.go", "-o", "main") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Stdin = os.Stdin + return cmd.Run() +} diff --git a/misc/go_mod_tidy.go b/misc/go_mod_tidy.go new file mode 100644 index 0000000..ab48c84 --- /dev/null +++ b/misc/go_mod_tidy.go @@ -0,0 +1,14 @@ +package misc + +import ( + "os" + "os/exec" +) + +func GoModTidy() error { + cmd := exec.Command("go", "mod", "tidy") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Stdin = os.Stdin + return cmd.Run() +} diff --git a/misc/go_test.go b/misc/go_test.go new file mode 100644 index 0000000..9b51cea --- /dev/null +++ b/misc/go_test.go @@ -0,0 +1,14 @@ +package misc + +import ( + "os" + "os/exec" +) + +func GoTest() error { + cmd := exec.Command("go", "test", "-v") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Stdin = os.Stdin + return cmd.Run() +}