few linting items
This commit is contained in:
parent
f68a770cf0
commit
5e4e253f58
4
merp.go
4
merp.go
@ -11,11 +11,11 @@ import "github.com/rs/zerolog/log"
|
|||||||
import "github.com/sneak/merp/models"
|
import "github.com/sneak/merp/models"
|
||||||
|
|
||||||
func thingRegex() *regexp.Regexp {
|
func thingRegex() *regexp.Regexp {
|
||||||
THING_REGEX, e := regexp.Compile(`^[a-zA-Z0-9\_\-]+$`)
|
ThingRegex, e := regexp.Compile(`^[a-zA-Z0-9\_\-]+$`)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
panic(e)
|
panic(e)
|
||||||
}
|
}
|
||||||
return THING_REGEX
|
return ThingRegex
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeJson(in []byte) interface{} {
|
func decodeJson(in []byte) interface{} {
|
||||||
|
13
models/db.go
13
models/db.go
@ -8,17 +8,17 @@ import _ "github.com/lib/pq"
|
|||||||
|
|
||||||
var ormObject orm.Ormer
|
var ormObject orm.Ormer
|
||||||
|
|
||||||
func Initialize() {
|
func initialize() {
|
||||||
if os.Getenv("DEBUG") != "" {
|
if os.Getenv("DEBUG") != "" {
|
||||||
orm.Debug = true
|
orm.Debug = true
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectToDb()
|
connectToDb()
|
||||||
SyncDB()
|
syncDB()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConnectToDb - Initializes the ORM and Connection to the postgres DB
|
// ConnectToDb - Initializes the ORM and Connection to the postgres DB
|
||||||
func ConnectToDb() {
|
func connectToDb() {
|
||||||
|
|
||||||
orm.DefaultTimeLoc = time.UTC
|
orm.DefaultTimeLoc = time.UTC
|
||||||
|
|
||||||
@ -35,7 +35,8 @@ func ConnectToDb() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func SyncDB() {
|
// SyncDB() is responsible for creating the schema in the database
|
||||||
|
func syncDB() {
|
||||||
// Database alias.
|
// Database alias.
|
||||||
name := "default"
|
name := "default"
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ func SyncDB() {
|
|||||||
// GetOrmObject - Getter function for the ORM object with which we can query the database
|
// GetOrmObject - Getter function for the ORM object with which we can query the database
|
||||||
func GetOrmObject() orm.Ormer {
|
func GetOrmObject() orm.Ormer {
|
||||||
if ormObject == nil {
|
if ormObject == nil {
|
||||||
Initialize()
|
initialize()
|
||||||
}
|
}
|
||||||
return ormObject
|
return ormObject
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package models
|
|||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
|
// Merps are the primary database item in merp
|
||||||
type Merp struct {
|
type Merp struct {
|
||||||
ID int `orm:"auto;column(id)"`
|
ID int `orm:"auto;column(id)"`
|
||||||
Content string `json:"content" orm:"type(jsonb);column(content)"`
|
Content string `json:"content" orm:"type(jsonb);column(content)"`
|
||||||
|
Loading…
Reference in New Issue
Block a user