diff --git a/domains/indexpage/indexpage.go b/domains/indexpage/indexpage.go index aaa15e8..293430f 100644 --- a/domains/indexpage/indexpage.go +++ b/domains/indexpage/indexpage.go @@ -42,7 +42,7 @@ func indexGet(ec echo.Context) error { // We should check if database connection available. dbConn := c.Database.GetDatabaseConnection() if c.Config.Database.Type != "flatfiles" && dbConn == nil { - ec.Redirect(http.StatusFound, "/database_not_available") + return ec.Redirect(http.StatusFound, "/database_not_available") } // Generate list of available languages to highlight. diff --git a/domains/pastes/paste_get.go b/domains/pastes/paste_get.go index fe129a9..c004e3c 100644 --- a/domains/pastes/paste_get.go +++ b/domains/pastes/paste_get.go @@ -77,11 +77,6 @@ func pasteGetData(pasteID int, timestamp int64, cookieValue string) (*structs.Pa return paste, "" } -// GET for "/api/paste/PASTE_ID" and "/api/paste/PASTE_ID/TIMESTAMP". -func pasteGETApi(ec echo.Context) error { - return nil -} - // GET for "/paste/PASTE_ID" and "/paste/PASTE_ID/TIMESTAMP" (private pastes). // Web interface version. func pasteGETWebInterface(ec echo.Context) error { diff --git a/domains/pastes/paste_post.go b/domains/pastes/paste_post.go index 6898413..53fba38 100644 --- a/domains/pastes/paste_post.go +++ b/domains/pastes/paste_post.go @@ -112,7 +112,7 @@ func pastePOSTWebInterface(ec echo.Context) error { } if pastePassword[0] != "" { - paste.CreatePassword(pastePassword[0]) + _ = paste.CreatePassword(pastePassword[0]) } id, err2 := c.Database.SavePaste(paste) diff --git a/domains/pastes/pastes_get.go b/domains/pastes/pastes_get.go index bb3ccff..b8dfcf1 100644 --- a/domains/pastes/pastes_get.go +++ b/domains/pastes/pastes_get.go @@ -79,7 +79,7 @@ func pastesGET(ec echo.Context) error { // Get max 4 lines of each paste. pasteDataSplitted := strings.Split(pastes[i].Data, "\n") - var pasteData = "" + var pasteData string if len(pasteDataSplitted) < 4 { pasteData = pastes[i].Data } else { diff --git a/internal/context/context.go b/internal/context/context.go index 13a8c23..83dcec9 100644 --- a/internal/context/context.go +++ b/internal/context/context.go @@ -32,7 +32,7 @@ import ( // local "go.dev.pztrn.name/fastpastebin/internal/config" - "go.dev.pztrn.name/fastpastebin/internal/database/interface" + databaseinterface "go.dev.pztrn.name/fastpastebin/internal/database/interface" // other "github.com/labstack/echo" @@ -60,7 +60,7 @@ func (c *Context) Initialize() { c.Flagger = flagger.New("fastpastebin", nil) c.Flagger.Initialize() - c.Flagger.AddFlag(&flagger.Flag{ + _ = c.Flagger.AddFlag(&flagger.Flag{ Name: "config", Description: "Configuration file path. Can be overridded with FASTPASTEBIN_CONFIG environment variable (this is what used in tests).", Type: "string", diff --git a/internal/context/http_server.go b/internal/context/http_server.go index 880cef0..a7096d9 100644 --- a/internal/context/http_server.go +++ b/internal/context/http_server.go @@ -40,8 +40,7 @@ func (c *Context) echoReqLogger() echo.MiddlewareFunc { Str("UA", ec.Request().UserAgent()). Msg("HTTP request") - next(ec) - return nil + return next(ec) } } } diff --git a/internal/database/dialects/flatfiles/flatfiles.go b/internal/database/dialects/flatfiles/flatfiles.go index 74059af..0b54ff5 100644 --- a/internal/database/dialects/flatfiles/flatfiles.go +++ b/internal/database/dialects/flatfiles/flatfiles.go @@ -169,10 +169,10 @@ func (ff *FlatFiles) Initialize() { ff.path = path c.Logger.Debug().Msgf("Storage path is now: %s", ff.path) - // Create directory if neccessary. + // Create directory if necessary. if _, err := os.Stat(ff.path); err != nil { c.Logger.Debug().Msgf("Directory '%s' does not exist, creating...", ff.path) - os.MkdirAll(ff.path, os.ModePerm) + _ = os.MkdirAll(ff.path, os.ModePerm) } else { c.Logger.Debug().Msgf("Directory '%s' already exists", ff.path) } @@ -180,7 +180,7 @@ func (ff *FlatFiles) Initialize() { // Create directory for pastes. if _, err := os.Stat(filepath.Join(ff.path, "pastes")); err != nil { c.Logger.Debug().Msgf("Directory '%s' does not exist, creating...", filepath.Join(ff.path, "pastes")) - os.MkdirAll(filepath.Join(ff.path, "pastes"), os.ModePerm) + _ = os.MkdirAll(filepath.Join(ff.path, "pastes"), os.ModePerm) } else { c.Logger.Debug().Msgf("Directory '%s' already exists", filepath.Join(ff.path, "pastes")) } diff --git a/internal/database/dialects/mysql/migrations/exported.go b/internal/database/dialects/mysql/migrations/exported.go index 93a3ef1..fcb4c5a 100644 --- a/internal/database/dialects/mysql/migrations/exported.go +++ b/internal/database/dialects/mysql/migrations/exported.go @@ -46,7 +46,7 @@ func New(cc *context.Context) { func Migrate() { c.Logger.Info().Msg("Migrating database...") - goose.SetDialect("mysql") + _ = goose.SetDialect("mysql") goose.AddNamedMigration("1_initial.go", InitialUp, nil) goose.AddNamedMigration("2_paste_lang.go", PasteLangUp, PasteLangDown) goose.AddNamedMigration("3_private_pastes.go", PrivatePastesUp, PrivatePastesDown) diff --git a/internal/database/dialects/mysql/mysqldatabase.go b/internal/database/dialects/mysql/mysqldatabase.go index f524ec3..e7bd25c 100644 --- a/internal/database/dialects/mysql/mysqldatabase.go +++ b/internal/database/dialects/mysql/mysqldatabase.go @@ -135,7 +135,7 @@ func (db *Database) Initialize() { // There might be only user, without password. MySQL/MariaDB driver // in DSN wants "user" or "user:password", "user:" is invalid. - var userpass = "" + var userpass string if c.Config.Database.Password == "" { userpass = c.Config.Database.Username } else { diff --git a/internal/database/dialects/postgresql/migrations/exported.go b/internal/database/dialects/postgresql/migrations/exported.go index 70801fc..5f76c48 100644 --- a/internal/database/dialects/postgresql/migrations/exported.go +++ b/internal/database/dialects/postgresql/migrations/exported.go @@ -46,7 +46,7 @@ func New(cc *context.Context) { func Migrate() { c.Logger.Info().Msg("Migrating database...") - goose.SetDialect("postgres") + _ = goose.SetDialect("postgres") goose.AddNamedMigration("1_initial.go", InitialUp, nil) goose.AddNamedMigration("2_paste_lang.go", PasteLangUp, PasteLangDown) goose.AddNamedMigration("3_private_pastes.go", PrivatePastesUp, PrivatePastesDown) diff --git a/internal/database/dialects/postgresql/postgresqldatabase.go b/internal/database/dialects/postgresql/postgresqldatabase.go index 6de54e1..61118f3 100644 --- a/internal/database/dialects/postgresql/postgresqldatabase.go +++ b/internal/database/dialects/postgresql/postgresqldatabase.go @@ -147,7 +147,7 @@ func (db *Database) GetPastesPages() int { func (db *Database) Initialize() { c.Logger.Info().Msg("Initializing database connection...") - var userpass = "" + var userpass string if c.Config.Database.Password == "" { userpass = c.Config.Database.Username } else { diff --git a/internal/pagination/exported.go b/internal/pagination/exported.go index 279bf0e..54768ce 100644 --- a/internal/pagination/exported.go +++ b/internal/pagination/exported.go @@ -33,7 +33,7 @@ func CreateHTML(currentPage int, pages int, linksBase string) string { } // First page should always be visible. - var paginationString = "" + var paginationString string if currentPage == 1 { paginationString = strings.Replace(string(paginationLinkCurrentRaw), "{pageNum}", strconv.Itoa(currentPage), -1) } else { diff --git a/internal/templater/exported.go b/internal/templater/exported.go index ca97750..3baed2a 100644 --- a/internal/templater/exported.go +++ b/internal/templater/exported.go @@ -58,7 +58,7 @@ func GetRawTemplate(ec echo.Context, templateName string, data map[string]string // Getting main template. tplRaw, err := static.ReadFile(templateName) if err != nil { - ec.String(http.StatusBadRequest, templateName+" not found.") + _ = ec.String(http.StatusBadRequest, templateName+" not found.") return "" } @@ -78,21 +78,21 @@ func GetTemplate(ec echo.Context, name string, data map[string]string) string { // Getting main template. mainhtml, err := static.ReadFile("main.html") if err != nil { - ec.String(http.StatusBadRequest, "main.html not found.") + _ = ec.String(http.StatusBadRequest, "main.html not found.") return "" } // Getting navigation. navhtml, err1 := static.ReadFile("navigation.html") if err1 != nil { - ec.String(http.StatusBadRequest, "navigation.html not found.") + _ = ec.String(http.StatusBadRequest, "navigation.html not found.") return "" } // Getting footer. footerhtml, err2 := static.ReadFile("footer.html") if err2 != nil { - ec.String(http.StatusBadRequest, "footer.html not found.") + _ = ec.String(http.StatusBadRequest, "footer.html not found.") return "" } @@ -105,7 +105,7 @@ func GetTemplate(ec echo.Context, name string, data map[string]string) string { // Get requested template. reqhtml, err3 := static.ReadFile(name) if err3 != nil { - ec.String(http.StatusBadRequest, name+" not found.") + _ = ec.String(http.StatusBadRequest, name+" not found.") return "" }