From eb6349f93ad467a96f61df067f45349d1f02ad08 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Thu, 13 Jun 2019 13:25:01 -0400 Subject: [PATCH] Allow compiling without go-sql-driver/mysql pkg This ensures the writefreely pkg can be used in other applications that need to load mysql themselves -- this can be done by building with the tag: wflib Ref T613 --- app.go | 2 -- database-lib.go | 20 ++++++++++++++++++++ database-no-sqlite.go | 2 +- database-sqlite.go | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 database-lib.go diff --git a/app.go b/app.go index 74a8598..cbff814 100644 --- a/app.go +++ b/app.go @@ -24,8 +24,6 @@ import ( "syscall" "time" - _ "github.com/go-sql-driver/mysql" - "github.com/gorilla/mux" "github.com/gorilla/schema" "github.com/gorilla/sessions" diff --git a/database-lib.go b/database-lib.go new file mode 100644 index 0000000..58beb05 --- /dev/null +++ b/database-lib.go @@ -0,0 +1,20 @@ +// +build wflib + +/* + * Copyright © 2019 A Bunch Tell LLC. + * + * This file is part of WriteFreely. + * + * WriteFreely is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, included + * in the LICENSE file in this source code package. + */ + +// This file contains dummy database funcs for when writefreely is used as a +// library. + +package writefreely + +func (db *datastore) isDuplicateKeyErr(err error) bool { + return false +} diff --git a/database-no-sqlite.go b/database-no-sqlite.go index 10db7d5..a3d50fc 100644 --- a/database-no-sqlite.go +++ b/database-no-sqlite.go @@ -1,4 +1,4 @@ -// +build !sqlite +// +build !sqlite,!wflib /* * Copyright © 2019 A Bunch Tell LLC. diff --git a/database-sqlite.go b/database-sqlite.go index 5fa3f6c..3741169 100644 --- a/database-sqlite.go +++ b/database-sqlite.go @@ -1,4 +1,4 @@ -// +build sqlite +// +build sqlite,!wflib /* * Copyright © 2019 A Bunch Tell LLC.