Skip to content

Commit

Permalink
fix: lint issues
Browse files Browse the repository at this point in the history
Signed-off-by: Pranshu Srivastava <[email protected]>
  • Loading branch information
PranshuSrivastava committed Sep 14, 2024
1 parent 5665c34 commit 9aca297
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions echo-sql/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func InsertURL(c context.Context, entry URLEntry) error {
`

selectQuery := `
SELECT *
SELECT *
FROM url_map
WHERE id = $1
`
Expand All @@ -100,7 +100,7 @@ func InsertURL(c context.Context, entry URLEntry) error {
if err != nil {
return err
}
defer handleDeferError(res.Close())
defer handleDeferError(res.Close)
if res.Next() { // If we get rows back, that means we have a duplicate URL
var savedEntry URLEntry
err := res.Scan(&savedEntry.ID, &savedEntry.RedirectURL, &savedEntry.CreatedAt, &savedEntry.UpdatedAt)
Expand Down Expand Up @@ -133,7 +133,7 @@ func GetURL(c echo.Context) error {
id := c.Param("param")

findURLQuery := `
SELECT *
SELECT *
FROM url_map
WHERE id = $1
`
Expand All @@ -143,7 +143,7 @@ func GetURL(c echo.Context) error {
Logger.Error(err.Error())
return echo.NewHTTPError(http.StatusInternalServerError, "Error encountered while attempting to lookup URL.")
}
defer handleDeferError(res.Close())
defer handleDeferError(res.Close)
if !res.Next() {
return echo.NewHTTPError(http.StatusNotFound, "Invalid URL ID.")
}
Expand Down Expand Up @@ -208,7 +208,7 @@ func UpdateURL(c echo.Context) error {
}

selectQuery := `
SELECT *
SELECT *
FROM url_map
WHERE id = $1
`
Expand All @@ -223,7 +223,7 @@ func UpdateURL(c echo.Context) error {
if err != nil {
return err
}
defer handleDeferError(res.Close())
defer handleDeferError(res.Close)
if res.Next() { // If we get rows back, that means we have a duplicate URL
var savedEntry URLEntry
err := res.Scan(&savedEntry.ID, &savedEntry.RedirectURL, &savedEntry.CreatedAt, &savedEntry.UpdatedAt)
Expand Down
12 changes: 6 additions & 6 deletions echo-sql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ var Logger *zap.Logger

var Database *sql.DB

func handleDeferError(err error) {
if err != nil {
Logger.Fatal(err.Error())
}
func handleDeferError(fn func() error) {

Check failure on line 24 in echo-sql/main.go

View workflow job for this annotation

GitHub Actions / lint (echo-sql)

File is not `gofmt`-ed with `-s` (gofmt)
if err := fn(); err != nil {
Logger.Error("error occurred during deferred call: %v", zap.Error(err))
}
}

func main() {
Expand All @@ -34,7 +34,7 @@ func main() {
}
var err error
Logger, _ = zap.NewProduction()
defer handleDeferError(Logger.Sync()) // flushes buffer
defer handleDeferError(Logger.Sync) // flushes buffer

Database, err = NewConnection(ConnectionDetails{
host: "postgresDb",
Expand All @@ -50,7 +50,7 @@ func main() {
Logger.Fatal("Failed to establish connection to local PostgreSQL instance:", zap.Error(err))
}

defer Database.Close()
defer handleDeferError(Database.Close)

// init Keploy

Expand Down

0 comments on commit 9aca297

Please sign in to comment.