fix(lint): resolve golangci-lint errors
Some checks failed
CI / Test (pull_request) Failing after 22s
CI / Lint (pull_request) Failing after 19s
CI / Build (pull_request) Failing after 6s
CI / Format Check (pull_request) Successful in 2s

- 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:
2025-11-06 10:28:48 +01:00
parent cd57fe7c14
commit 767654f257
2 changed files with 27 additions and 24 deletions

View File

@@ -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
// }

View File

@@ -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