Page MenuHomeMusing Studio

No OneTemporary

diff --git a/config.go b/config.go
new file mode 100644
index 0000000..51e3a19
--- /dev/null
+++ b/config.go
@@ -0,0 +1,7 @@
+// +build !debug
+
+package main
+
+const (
+ DEBUG = false
+)
diff --git a/config_debug.go b/config_debug.go
new file mode 100644
index 0000000..81353ef
--- /dev/null
+++ b/config_debug.go
@@ -0,0 +1,7 @@
+// +build debug
+
+package main
+
+const (
+ DEBUG = true
+)
diff --git a/posts.go b/posts.go
index 7aa9581..75a08ed 100644
--- a/posts.go
+++ b/posts.go
@@ -1,39 +1,46 @@
package main
import (
"fmt"
"github.com/writeas/writeas-cli/utils"
"os"
"path/filepath"
)
const (
POSTS_FILE = "posts.psv"
SEPARATOR = `|`
)
func userDataDir() string {
return filepath.Join(parentDataDir(), DATA_DIR_NAME)
}
func dataDirExists() bool {
return fileutils.Exists(userDataDir())
}
func createDataDir() {
- os.Mkdir(userDataDir(), 0700)
+ err := os.Mkdir(userDataDir(), 0700)
+ if err != nil && DEBUG {
+ panic(err)
+ }
}
func addPost(id, token string) {
f, err := os.OpenFile(filepath.Join(userDataDir(), POSTS_FILE), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0600)
if err != nil {
- panic(err)
+ if DEBUG {
+ panic(err)
+ } else {
+ return
+ }
}
defer f.Close()
l := fmt.Sprintf("%s%s%s\n", id, SEPARATOR, token)
- if _, err = f.WriteString(l); err != nil {
+ if _, err = f.WriteString(l); err != nil && DEBUG {
panic(err)
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Nov 25, 3:26 AM (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3106541

Event Timeline