change filepath to script

This commit is contained in:
Niklas 2019-11-04 21:19:05 +01:00
parent d06d136601
commit 8223e02e50
1 changed files with 14 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import (
"io/ioutil"
"log"
"os"
"path/filepath"
"regexp"
"strings"
@ -62,7 +63,7 @@ func isPGPMessage(msg string) (bool, error) {
return matched, err
}
func isEncrypted(mail *message.Entity) (bool) {
func isEncrypted(mail *message.Entity) bool {
t, _, _ := mail.Header.ContentType()
if strings.ToLower(t) == "multipart/encrypted" {
return true
@ -131,6 +132,18 @@ func encryptEML(eml string, armoredKeyRing *string) {
}
func main() {
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
log.Fatal(err)
}
if !strings.HasPrefix(dir, os.TempDir()) {
err = os.Chdir(dir)
if err != nil {
log.Fatal(err)
}
}
cfg, err := ini.Load("config.ini")
if err != nil {
fmt.Printf("Fail to read file: %v", err)