Skip to content

Commit

Permalink
filepath fix
Browse files Browse the repository at this point in the history
  • Loading branch information
plainbanana committed Jun 20, 2020
1 parent 6eb776d commit 63cee23
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"net/url"
"os"
"path"
"path/filepath"
"strings"
"time"

Expand All @@ -31,11 +32,12 @@ var (
mastodonAppYourPassword = ""

timezone = time.FixedZone("Asia/Tokyo", 9*60*60)

chacheFile = "api_chache.gob"
)

const (
splatoon2API = "https://spla2.yuu26.com"
chacheFile = "./api_chache.gob"
tootTimeFormat = "2006-01-02 15:04 -07:00"

tootNoMention tootConfig = "nomention"
Expand Down Expand Up @@ -75,6 +77,15 @@ type splatoonRespSchedules struct {
}

func init() {
exe, err := os.Executable()
if !errors.Is(err, nil) {
log.Fatal(err)
}
if p := filepath.Dir(exe); !strings.Contains(p, "go-build") {
chacheFile = filepath.Join(p, chacheFile)
}
log.Println("chache file is", chacheFile)

if s := os.Getenv("USERAGENT"); s != "" {
userAgent = s
}
Expand Down

0 comments on commit 63cee23

Please sign in to comment.