fix(lint): resolve golangci-lint errors
- Fix errcheck: explicitly ignore tx.Rollback() error in defer - When transaction commits successfully, Rollback() returns an error (expected) - Use defer func() with explicit error assignment to satisfy linter - Remove unused connectToService function - Function is not currently used (proto files not yet generated) - Commented out with TODO for future implementation - Prevents unused function lint error
This commit is contained in:
@@ -50,26 +50,27 @@ func (c *AuthClient) Logout(ctx context.Context, refreshToken string) error {
|
|||||||
return fmt.Errorf("not implemented: proto files not yet generated")
|
return fmt.Errorf("not implemented: proto files not yet generated")
|
||||||
}
|
}
|
||||||
|
|
||||||
// connectToService discovers and connects to a service instance.
|
// TODO: connectToService will be implemented when proto files are generated
|
||||||
func connectToService(ctx context.Context, reg registry.ServiceRegistry, serviceName string) (*grpc.ClientConn, error) {
|
// This function will discover and connect to a service instance via gRPC.
|
||||||
instances, err := reg.Discover(ctx, serviceName)
|
// func connectToService(ctx context.Context, reg registry.ServiceRegistry, serviceName string) (*grpc.ClientConn, error) {
|
||||||
if err != nil {
|
// instances, err := reg.Discover(ctx, serviceName)
|
||||||
return nil, fmt.Errorf("failed to discover service %s: %w", serviceName, err)
|
// if err != nil {
|
||||||
}
|
// return nil, fmt.Errorf("failed to discover service %s: %w", serviceName, err)
|
||||||
|
// }
|
||||||
if len(instances) == 0 {
|
//
|
||||||
return nil, fmt.Errorf("no instances found for service %s", serviceName)
|
// if len(instances) == 0 {
|
||||||
}
|
// return nil, fmt.Errorf("no instances found for service %s", serviceName)
|
||||||
|
// }
|
||||||
// Use the first healthy instance (load balancing can be added later)
|
//
|
||||||
instance := instances[0]
|
// // Use the first healthy instance (load balancing can be added later)
|
||||||
address := fmt.Sprintf("%s:%d", instance.Address, instance.Port)
|
// instance := instances[0]
|
||||||
|
// address := fmt.Sprintf("%s:%d", instance.Address, instance.Port)
|
||||||
// Create gRPC connection
|
//
|
||||||
conn, err := grpc.NewClient(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
// // Create gRPC connection
|
||||||
if err != nil {
|
// conn, err := grpc.NewClient(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||||
return nil, fmt.Errorf("failed to connect to %s at %s: %w", serviceName, address, err)
|
// if err != nil {
|
||||||
}
|
// return nil, fmt.Errorf("failed to connect to %s at %s: %w", serviceName, address, err)
|
||||||
|
// }
|
||||||
return conn, nil
|
//
|
||||||
}
|
// return conn, nil
|
||||||
|
// }
|
||||||
|
|||||||
@@ -97,7 +97,9 @@ func createSchemaIfNotExists(ctx context.Context, db *sql.DB, schemaName string)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer tx.Rollback()
|
defer func() {
|
||||||
|
_ = tx.Rollback() // Ignore error - if commit succeeded, rollback will error (expected)
|
||||||
|
}()
|
||||||
|
|
||||||
// Check if schema exists
|
// Check if schema exists
|
||||||
var exists bool
|
var exists bool
|
||||||
|
|||||||
Reference in New Issue
Block a user