Skip to content

Commit aabe0a9

Browse files
authored
Merge pull request #130 from karthikkalarikal/fix-linter-issues
Fix linter issues
2 parents 9668296 + b943a7f commit aabe0a9

27 files changed

Lines changed: 161 additions & 93 deletions

File tree

S3-Keploy/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"S3-Keploy/config"
66
"S3-Keploy/routes"
77
"log"
8+
"os"
89
"time"
910

1011
"github.com/gofiber/fiber/v2"
@@ -20,6 +21,7 @@ func main() {
2021

2122
err := app.Listen(":3000")
2223
if err != nil {
23-
log.Fatal(err)
24+
log.Printf("%s", err)
25+
os.Exit(1)
2426
}
2527
}

echo-mysql/main.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
// Package main starts the application
1+
// Package main initializes and starts a URL shortening service using Echo framework,
2+
// connecting to a MySQL database and providing endpoints for shortening and resolving URLs
23
package main
34

45
import (
56
"fmt"
67
"log"
78
"net/http"
9+
"os"
810
"time"
911

1012
"github.com/hermione/echo-mysql/uss"
@@ -17,15 +19,17 @@ func main() {
1719
time.Sleep(2 * time.Second)
1820
appConfig, err := godotenv.Read()
1921
if err != nil {
20-
log.Fatalf("Error reading .env file %s", err.Error())
22+
log.Printf("Error reading .env file %s", err.Error())
23+
os.Exit(1)
24+
2125
}
2226

2327
uss.MetaStore = &uss.Store{}
2428
err = uss.MetaStore.Connect(appConfig)
2529
if err != nil {
26-
log.Fatalf("Failed to connect to db %s", err.Error())
30+
log.Printf("Failed to connect to db %s", err.Error())
31+
os.Exit(1)
2732
}
28-
2933
StartHTTPServer()
3034
}
3135

echo-mysql/uss/short.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Package uss generates short links using SHA-256 and Base58 encoding. Provides methods to connect to and interact with a MySQL database
2-
// for storing and retrieving short URLs.
1+
// Package uss provides utility functions for generating short, unique URL links by hashing and encoding input URLs
32
package uss
43

54
import (

echo-mysql/uss/store.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"gorm.io/gorm"
1111
)
1212

13+
var MetaStore *Store
14+
1315
type ShortCodeInfo struct {
1416
UID uint64 `json:"id" sql:"AUTO_INCREMENT" gorm:"primary_key"`
1517
ShortCode string `json:"shortcode" gorm:"uniqueIndex"`
@@ -50,8 +52,8 @@ func (s *Store) Connect(config map[string]string) error {
5052
sqlDB.SetMaxOpenConns(512)
5153

5254
if err = s.db.AutoMigrate(&ShortCodeInfo{}); err != nil {
53-
log.Printf("Failed to create/update db tables with error %s", err.Error())
54-
return err
55+
log.Printf("%s", fmt.Sprintf("Failed to create/update db tables with error %s", err.Error()))
56+
os.Exit(1)
5557
}
5658

5759
return nil
@@ -61,6 +63,7 @@ func (s *Store) Close() {
6163
db, _ := s.db.DB()
6264
if err := db.Close(); err != nil {
6365
fmt.Fprintf(os.Stderr, "Could not close database connection: %v\n", err)
66+
os.Exit(1)
6467
}
6568
}
6669

@@ -79,5 +82,3 @@ func (s *Store) FindByShortCode(shortCode string) *ShortCodeInfo {
7982
urlInfo := infos[0]
8083
return &urlInfo
8184
}
82-
83-
var MetaStore *Store

fasthttp-postgres/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
app
1+
22
coverage-reports/

fasthttp-postgres/internal/repository/repository.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Package repository provides functions to interact with the database for authors and books.
2+
// It includes methods to fetch, create, and manage data related to authors and books.
13
package repository
24

35
import (

gin-redis/helpers/redis/redisConnect.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package redis
33

44
import (
55
"log"
6+
"os"
67

78
"github.com/go-redis/redis"
89
)
@@ -22,6 +23,7 @@ func Init() {
2223
})
2324
_, err := RedisClient.Ping().Result()
2425
if err != nil {
25-
log.Fatalf("Error initializing Redis client: %v", err)
26+
log.Printf("Error initializing Redis client: %v", err)
27+
os.Exit(1)
2628
}
2729
}

gin-redis/helpers/token/token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func GenerateToken(value string, secretKey string) (string, error) {
3434
}
3535

3636
func VerifyToken(tokenString string, secretKey string) (*CustomClaims, error) {
37-
token, err := jwt.ParseWithClaims(tokenString, &CustomClaims{}, func(_ *jwt.Token) (interface{}, error) {
37+
token, err := jwt.ParseWithClaims(tokenString, &CustomClaims{}, func(*jwt.Token) (interface{}, error) {
3838
return []byte(secretKey), nil
3939
})
4040

gin-redis/server/server.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
// Package server sets up and manages the HTTP server with routes and graceful shutdown.
1+
// Package server manages the HTTP server setup and graceful shutdown.
2+
// It initializes the server, starts it, and ensures it shuts down properly when receiving interrupt signals.
23
package server
34

45
import (
56
"context"
67
"fmt"
7-
"github.com/keploy/gin-redis/routes"
88
"net/http"
99
"os"
1010
"os/signal"
1111
"syscall"
1212
"time"
13+
14+
"github.com/keploy/gin-redis/routes"
1315
)
1416

1517
func Init() {

go-grpc/client/client.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"io"
77
"log"
88
"net/http"
9+
"os"
910

1011
pb "github.com/keploy/samples-go/go-grpc/user"
1112

@@ -23,7 +24,8 @@ func init() {
2324
// Set up the gRPC connection
2425
conn, err := grpc.NewClient("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
2526
if err != nil {
26-
log.Fatalf("failed to connect to gRPC server: %v", err)
27+
log.Printf("failed to connect to gRPC server: %v", err)
28+
os.Exit(1)
2729
}
2830
grpcClient = pb.NewUserServiceClient(conn)
2931
}
@@ -327,8 +329,8 @@ func main() {
327329
r.DELETE("/users/stream", deleteUsersStream)
328330

329331
// Start Gin server
330-
err := r.Run(":8080")
331-
if err != nil && err != http.ErrServerClosed {
332-
log.Fatalf("Failed to start server: %v", err)
332+
if err := r.Run(":8080"); err != nil {
333+
log.Printf("%s", err)
334+
os.Exit(1)
333335
}
334336
}

0 commit comments

Comments
 (0)