summaryrefslogtreecommitdiff
path: root/dscuss.go
diff options
context:
space:
mode:
authorVitaly Minko <vitaly.minko@gmail.com>2018-09-10 17:46:11 +0300
committerVitaly Minko <vitaly.minko@gmail.com>2018-09-10 17:46:11 +0300
commit6f9d7f84c3b31a82b6bd885a68621aded28c8a66 (patch)
treea6d456b0d3750661c8072192f2417b432ec52904 /dscuss.go
parent521ffe0e4f75e4d1070ec29edc8b6976125f8961 (diff)
Now it's possible to send messaged between peers.
Diffstat (limited to 'dscuss.go')
-rw-r--r--dscuss.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/dscuss.go b/dscuss.go
index a8d6c39..df1351d 100644
--- a/dscuss.go
+++ b/dscuss.go
@@ -34,6 +34,7 @@ import (
"vminko.org/dscuss/p2p"
"vminko.org/dscuss/sqlite"
"vminko.org/dscuss/storage"
+ dstrings "vminko.org/dscuss/strings"
)
const (
@@ -64,13 +65,17 @@ func Init(initDir string) error {
dir = initDir
}
- if dir[:2] == "~/" {
+ if dstrings.Truncate(dir, 2) == "~/" {
usr, err := user.Current()
if err != nil {
- log.Error("Can't get get current OS user: " + err.Error())
+ log.Error("Can't get current OS user: " + err.Error())
return errors.Internal
}
- dir = filepath.Join(usr.HomeDir, dir[2:])
+ if len(dir) > 2 {
+ dir = filepath.Join(usr.HomeDir, dir[2:])
+ } else {
+ dir = usr.HomeDir
+ }
}
if _, err := os.Stat(dir); os.IsNotExist(err) {