You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered an issue when using a generic type T in combination with the linter setting check-type-param: true. The following code results in a linting error:
func NewStorageValueUnexpectedError[T int | string](key string, value T, cause error) *UnexpectedStorageValueError[T] {
var ger *GenInfraError
if cause != nil {
ger = NewGenInfraErrorWithCause(fmt.Sprintf("Unexpected value '%v' of '%s'", value, key), cause)
} else {
ger = NewGenInfraError(fmt.Sprintf("Unexpected value '%v' of '%s'", value, key))
}
return &UnexpectedStorageValueError[T]{
value: value,
key: key,
GenInfraError: ger,
}
}
I am getting the following error
internal/infrastructure/infraerr/err__unexpected.go:15:37: type parameter name 'T' is too short for the scope of its usage (varnamelen)
func NewStorageValueUnexpectedError[T int | string](key string, value T, cause error) *UnexpectedStorageValueError[T] {
^
make: *** [Makefile:40: lint-go] Error 1
Question:
When check-type-param is enabled, should commonly used single-character generic types like T be renamed to something more descriptive? Or is there a recommended way to handle such cases without violating the rule?
Any guidance or clarification on the expected behavior would be appreciated.
The text was updated successfully, but these errors were encountered:
I encountered an issue when using a generic type T in combination with the linter setting check-type-param: true. The following code results in a linting error:
I am getting the following error
Question:
When check-type-param is enabled, should commonly used single-character generic types like T be renamed to something more descriptive? Or is there a recommended way to handle such cases without violating the rule?
Any guidance or clarification on the expected behavior would be appreciated.
The text was updated successfully, but these errors were encountered: