From c9f3733aee209eb451b163e4ab92e31ad100b5a6 Mon Sep 17 00:00:00 2001 From: Greg Date: Mon, 28 Oct 2019 12:46:57 -0400 Subject: [PATCH] Add stub android implementation. --- .gitignore | 1 + go.mod | 2 +- go.sum | 2 ++ main.go | 2 +- os_android.go | 15 +++++++++++++++ os_darwin.go | 6 +++++- 6 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 os_android.go diff --git a/.gitignore b/.gitignore index f063deb..c004169 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ hrm +*.apk diff --git a/go.mod b/go.mod index b67133f..786bb77 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,6 @@ go 1.13 require ( gioui.org v0.0.0-20191028123051-439d3e652c8f - git.wow.st/gmp/ble v0.0.0-20191028152114-c911bbb547bc + git.wow.st/gmp/ble v0.0.0-20191028164333-f036c5e1346f gopkg.in/yaml.v2 v2.2.4 ) diff --git a/go.sum b/go.sum index 2653bfa..104059c 100644 --- a/go.sum +++ b/go.sum @@ -11,6 +11,8 @@ git.wow.st/gmp/ble v0.0.0-20191028132523-2d4f106dd76c h1:GUCh9nytD5hEqw8B5/vXtY8 git.wow.st/gmp/ble v0.0.0-20191028132523-2d4f106dd76c/go.mod h1:MiidWVofL6FTtRokC5JGBdVUhKyvZtnia5noj08r944= git.wow.st/gmp/ble v0.0.0-20191028152114-c911bbb547bc h1:wh2wjBt1/b+pH9PPP2TJZzv8HjpwsN0t+rN6dRwAfvY= git.wow.st/gmp/ble v0.0.0-20191028152114-c911bbb547bc/go.mod h1:MiidWVofL6FTtRokC5JGBdVUhKyvZtnia5noj08r944= +git.wow.st/gmp/ble v0.0.0-20191028164333-f036c5e1346f h1:QcNTjwSAe+/+2jdeeKx3EjS3CPv4Ur8AVrVlFfMquck= +git.wow.st/gmp/ble v0.0.0-20191028164333-f036c5e1346f/go.mod h1:MiidWVofL6FTtRokC5JGBdVUhKyvZtnia5noj08r944= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/main.go b/main.go index b0a5ad6..aa1c48b 100644 --- a/main.go +++ b/main.go @@ -31,7 +31,7 @@ var Config conf var conffile string func main() { - conffile = path.Join(confDir, "config.yml") + conffile = path.Join(getConfDir(), "config.yml") if _, err := os.Stat(conffile); os.IsNotExist(err) { fd, err := os.Create(conffile) if err != nil { diff --git a/os_android.go b/os_android.go new file mode 100644 index 0000000..3111622 --- /dev/null +++ b/os_android.go @@ -0,0 +1,15 @@ +package main + +import ( + "gioui.org/app" +) + +var confDir string + +func getConfDir() string { + if confDir != "" { + return confDir + } + confDir,_ = app.DataDir() + return confDir +} diff --git a/os_darwin.go b/os_darwin.go index fad4fdb..90127a3 100644 --- a/os_darwin.go +++ b/os_darwin.go @@ -9,7 +9,10 @@ import ( var confDir string -func init() { +func getConfDir() string { + if confDir != "" { + return confDir + } usr, err := user.Current() if err != nil { log.Fatal("Cannot get current user: ", err) @@ -23,4 +26,5 @@ func init() { log.Print("Configuration directory created") } } + return confDir }