Files
tasks/common/rpc/request_issues.go
Stephan BehnkeandGitHub c9e360a3fb go fix (#9337)
## What changed?

Integrate Go 1.26's new `go fix` into workflow.

NOTE that the changes caused our linter to fire; a [separate
commit](https://github.com/temporalio/temporal/pull/9337/commits/1b23f787aef370098b35829c4d17dcc06230b4c1)
addresses those.

## Why?

Ensure Go code is standardized/modernized.

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [x] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
2026-02-18 09:12:19 -08:00

33 lines
818 B
Go

package rpc
import (
"fmt"
"strings"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// RequestIssues is a collection of request validation issues for an RPC. The zero value is valid to use.
type RequestIssues struct {
issues []string
}
// Append an issue to the set.
func (ri *RequestIssues) Append(issue string) {
ri.issues = append(ri.issues, issue)
}
// Appendf appends a formatted issue to the set.
func (ri *RequestIssues) Appendf(format string, args ...any) {
ri.Append(fmt.Sprintf(format, args...))
}
// GetError returns a gRPC INVALID_ARGUMENT error representing the issues in the set or nil if there are no issues.
func (ri *RequestIssues) GetError() error {
if len(ri.issues) == 0 {
return nil
}
return status.Error(codes.InvalidArgument, strings.Join(ri.issues, ", "))
}