Refactor project structure

pull/8/head
isthisnagee 3 years ago
parent e3d511db69
commit 06891059ac

@ -0,0 +1,31 @@
package main
import (
"errors"
"isthisnagee.com/tools/eng-log/db"
"log"
"os"
"path"
)
func main() {
home_dir, err := os.UserHomeDir()
if err != nil {
log.Fatal(err.Error())
}
var db_path = path.Join(home_dir, ".dev-log.sql")
if _, err := os.Stat(db_path); errors.Is(err, os.ErrNotExist) {
_, err := os.Create(db_path)
if err != nil {
log.Fatal(err.Error())
}
}
_, err = db.Init(db_path)
if err != nil {
log.Fatal(err.Error())
}
}

@ -1,4 +1,4 @@
package main package db
import ( import (
"context" "context"
@ -6,9 +6,6 @@ import (
"errors" "errors"
"fmt" "fmt"
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
"log"
"os"
"path"
) )
var __version = 1 var __version = 1
@ -71,29 +68,3 @@ func Init(db_location string) (*LogCtx, error) {
return &LogCtx{db, version}, nil return &LogCtx{db, version}, nil
} }
func (db *LogCtx) AddEntry(title string) int {
return 1
}
func main() {
home_dir, err := os.UserHomeDir()
if err != nil {
log.Fatal(err.Error())
}
var db_path = path.Join(home_dir, ".dev-log.sql")
if _, err := os.Stat(db_path); errors.Is(err, os.ErrNotExist) {
_, err := os.Create(db_path)
if err != nil {
log.Fatal(err.Error())
}
}
_, err = Init(db_path)
if err != nil {
log.Fatal(err.Error())
}
}

@ -1,4 +1,4 @@
package main package db
import ( import (
"database/sql" "database/sql"
Loading…
Cancel
Save