Skip to content

Instantly share code, notes, and snippets.

@meoow
Created January 5, 2023 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meoow/3549fa5eaa91eacf0b027585107e5cab to your computer and use it in GitHub Desktop.
Save meoow/3549fa5eaa91eacf0b027585107e5cab to your computer and use it in GitHub Desktop.
A wrap for voltiageshift
package main
import (
"flag"
"os"
"path/filepath"
"syscall"
)
func main() {
flag.Parse()
ex, err := os.Executable()
if err != nil {
panic(err)
}
ex, err = filepath.EvalSymlinks(ex)
if err != nil {
panic(err)
}
selfdir := filepath.Dir(ex)
realrt := "voltageshift"
realfullrt := filepath.Join(selfdir, realrt)
if fi, ok := os.Stat(realfullrt); ok == nil {
if fi.IsDir() {
os.Stderr.WriteString("[ERROR] Cannot find voltageshift\n")
os.Exit(1)
}
} else {
os.Stderr.WriteString("[ERROR] Cannot find voltageshift\n")
os.Exit(1)
}
os.Chdir(selfdir)
argvs := []string{realfullrt}
if flag.NArg() > 0 {
argvs = append(argvs, flag.Args()...)
}
syscall.Exec(realfullrt, argvs, syscall.Environ())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment