Skip to content

Instantly share code, notes, and snippets.

@runo280
Last active May 21, 2020 00:02
Show Gist options
  • Save runo280/c01ca7acd9cf03e6b35487e5945cfcaa to your computer and use it in GitHub Desktop.
Save runo280/c01ca7acd9cf03e6b35487e5945cfcaa to your computer and use it in GitHub Desktop.
Telegram
package main
import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
)
//go build -ldflags -w
func main() {
filename := os.Args[0] // get command line first parameter
file := filepath.Base(filename)
_ = os.Mkdir("t"+file, os.ModePerm)
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
log.Fatal(err)
}
fmt.Println(dir)
// linux
path := fmt.Sprintf("%s/t"+file, dir)
telegram := fmt.Sprintf("%s/Telegram", dir)
//win
//path := fmt.Sprintf("%s\\t"+file, dir)
//telegram := fmt.Sprintf("%s\\Telegram", dir)
cmd := exec.Command(telegram, "-many", "-workdir", path)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err2 := cmd.Run()
if err2 != nil {
log.Fatalf("cmd.Run() failed with %s\n", err2)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment