Change the project layout
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
dbpkg "nkeller.dev/blog_software/db"
|
||||
usrpkg "nkeller.dev/blog_software/user"
|
||||
)
|
||||
|
||||
type Post struct {
|
||||
id int
|
||||
created_at int
|
||||
creator_id int
|
||||
title string
|
||||
description string
|
||||
content string
|
||||
tags string
|
||||
}
|
||||
|
||||
func main() {
|
||||
// DB and Migrations
|
||||
db, err := sql.Open("sqlite3", "./db/blogging.db")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer db.Close()
|
||||
migrations := [...]string{
|
||||
"1784776258",
|
||||
}
|
||||
dbpkg.Migrate(db, migrations[:])
|
||||
|
||||
user, err := usrpkg.Create(db, "profilelag2", "Hello")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(user)
|
||||
fmt.Printf("user: %v\n", user)
|
||||
}
|
||||
Reference in New Issue
Block a user