Make linter happy and move to os from io/ioutil for reading/writing.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -36,7 +36,7 @@ var (
|
||||
|
||||
func New(cc *context.Context) {
|
||||
ctx = cc
|
||||
// nolint:exhaustruct
|
||||
//nolint:exhaustruct
|
||||
dbAdapter = &Database{}
|
||||
|
||||
ctx.Database.RegisterDialect(dialectinterface.Interface(Handler{}))
|
||||
|
@@ -48,7 +48,7 @@ func InitialUp(tx *sql.Tx) error {
|
||||
COMMENT ON COLUMN pastes.keep_for_unit_type IS 'Keep for unit type. 0 - forever, 1 - minutes, 2 - hours, 3 - days, 4 - months.';
|
||||
`)
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
//nolint:wrapcheck
|
||||
return err
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,7 @@ import (
|
||||
func PasteLangUp(tx *sql.Tx) error {
|
||||
_, err := tx.Exec("ALTER TABLE pastes ADD COLUMN language VARCHAR(191) NOT NULL DEFAULT 'text'; COMMENT ON COLUMN pastes.language IS 'Paste language';")
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
//nolint:wrapcheck
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func PasteLangUp(tx *sql.Tx) error {
|
||||
func PasteLangDown(tx *sql.Tx) error {
|
||||
_, err := tx.Exec("ALTER TABLE pastes DROP COLUMN language")
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
//nolint:wrapcheck
|
||||
return err
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,7 @@ import (
|
||||
func PrivatePastesUp(tx *sql.Tx) error {
|
||||
_, err := tx.Exec("ALTER TABLE pastes ADD COLUMN private BOOLEAN NOT NULL DEFAULT false; COMMENT ON COLUMN pastes.private IS 'Private paste? If true - additional URL parameter (UNIX TIMESTAMP) of paste will be required to access.';")
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
//nolint:wrapcheck
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func PrivatePastesUp(tx *sql.Tx) error {
|
||||
func PrivatePastesDown(tx *sql.Tx) error {
|
||||
_, err := tx.Exec("ALTER TABLE pastes DROP COLUMN private")
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
//nolint:wrapcheck
|
||||
return err
|
||||
}
|
||||
|
||||
|
@@ -31,13 +31,13 @@ import (
|
||||
func PasswordedPastesUp(txn *sql.Tx) error {
|
||||
_, err := txn.Exec("ALTER TABLE pastes ADD COLUMN password VARCHAR(64) NOT NULL DEFAULT ''; COMMENT ON COLUMN pastes.password IS 'Password for paste (scrypted and sha256ed).';")
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
//nolint:wrapcheck
|
||||
return err
|
||||
}
|
||||
|
||||
_, err1 := txn.Exec("ALTER TABLE pastes ADD COLUMN password_salt VARCHAR(64) NOT NULL DEFAULT ''; COMMENT ON COLUMN pastes.password_salt IS 'Password salt (sha256ed).';")
|
||||
if err1 != nil {
|
||||
// nolint:wrapcheck
|
||||
//nolint:wrapcheck
|
||||
return err1
|
||||
}
|
||||
|
||||
@@ -47,13 +47,13 @@ func PasswordedPastesUp(txn *sql.Tx) error {
|
||||
func PasswordedPastesDown(txn *sql.Tx) error {
|
||||
_, err := txn.Exec("ALTER TABLE pastes DROP COLUMN password")
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
//nolint:wrapcheck
|
||||
return err
|
||||
}
|
||||
|
||||
_, err1 := txn.Exec("ALTER TABLE pastes DROP COLUMN password_salt")
|
||||
if err1 != nil {
|
||||
// nolint:wrapcheck
|
||||
//nolint:wrapcheck
|
||||
return err1
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
package postgresql
|
||||
|
||||
// nolint:gci
|
||||
//nolint:gci
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
@@ -63,7 +63,7 @@ func (db *Database) DeletePaste(pasteID int) error {
|
||||
|
||||
_, err := db.db.Exec(db.db.Rebind("DELETE FROM pastes WHERE id=?"), pasteID)
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
//nolint:wrapcheck
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -84,12 +84,12 @@ func (db *Database) GetDatabaseConnection() *sql.DB {
|
||||
func (db *Database) GetPaste(pasteID int) (*structs.Paste, error) {
|
||||
db.check()
|
||||
|
||||
// nolint:exhaustruct
|
||||
//nolint:exhaustruct
|
||||
paste := &structs.Paste{}
|
||||
|
||||
err := db.db.Get(paste, db.db.Rebind("SELECT * FROM pastes WHERE id=$1"), pasteID)
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
//nolint:wrapcheck
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ func (db *Database) GetPagedPastes(page int) ([]structs.Paste, error) {
|
||||
|
||||
err := db.db.Select(&pastesRaw, db.db.Rebind("SELECT * FROM pastes WHERE private != true ORDER BY id DESC LIMIT $1 OFFSET $2"), ctx.Config.Pastes.Pagination, startPagination)
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
//nolint:wrapcheck
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ func (db *Database) SavePaste(paste *structs.Paste) (int64, error) {
|
||||
|
||||
stmt, err := db.db.PrepareNamed("INSERT INTO pastes (title, data, created_at, keep_for, keep_for_unit_type, language, private, password, password_salt) VALUES (:title, :data, :created_at, :keep_for, :keep_for_unit_type, :language, :private, :password, :password_salt) RETURNING id")
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
//nolint:wrapcheck
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ func (db *Database) SavePaste(paste *structs.Paste) (int64, error) {
|
||||
|
||||
err = stmt.Get(&newPasteID, paste)
|
||||
if err != nil {
|
||||
// nolint:wrapcheck
|
||||
//nolint:wrapcheck
|
||||
return 0, err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user