Merge branch 'linting' of fastpastebin/fastpastebin into master
This commit is contained in:
commit
9c9f0c1f68
@ -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.
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -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",
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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"))
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 ""
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user