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")
|
||||
}
|
||||
|
||||
// connectToService discovers and connects to a service instance.
|
||||
func connectToService(ctx context.Context, reg registry.ServiceRegistry, serviceName string) (*grpc.ClientConn, error) {
|
||||
instances, err := reg.Discover(ctx, serviceName)
|
||||
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)
|
||||
}
|
||||
|
||||
// Use the first healthy instance (load balancing can be added later)
|
||||
instance := instances[0]
|
||||
address := fmt.Sprintf("%s:%d", instance.Address, instance.Port)
|
||||
|
||||
// Create gRPC connection
|
||||
conn, err := grpc.NewClient(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to connect to %s at %s: %w", serviceName, address, err)
|
||||
}
|
||||
|
||||
return conn, nil
|
||||
}
|
||||
// TODO: connectToService will be implemented when proto files are generated
|
||||
// This function will discover and connect to a service instance via gRPC.
|
||||
// func connectToService(ctx context.Context, reg registry.ServiceRegistry, serviceName string) (*grpc.ClientConn, error) {
|
||||
// instances, err := reg.Discover(ctx, serviceName)
|
||||
// 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)
|
||||
// }
|
||||
//
|
||||
// // Use the first healthy instance (load balancing can be added later)
|
||||
// instance := instances[0]
|
||||
// address := fmt.Sprintf("%s:%d", instance.Address, instance.Port)
|
||||
//
|
||||
// // Create gRPC connection
|
||||
// conn, err := grpc.NewClient(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
// if err != nil {
|
||||
// return nil, fmt.Errorf("failed to connect to %s at %s: %w", serviceName, address, err)
|
||||
// }
|
||||
//
|
||||
// return conn, nil
|
||||
// }
|
||||
|
||||
@@ -97,7 +97,9 @@ func createSchemaIfNotExists(ctx context.Context, db *sql.DB, schemaName string)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
defer func() {
|
||||
_ = tx.Rollback() // Ignore error - if commit succeeded, rollback will error (expected)
|
||||
}()
|
||||
|
||||
// Check if schema exists
|
||||
var exists bool
|
||||
|
||||
Reference in New Issue
Block a user