avoid "any" as variable name

Avoid shadowing / confusion with Go's "any" built-in type.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2023-06-10 13:49:06 +02:00
parent ee2c8b79bf
commit 4bb709c018
25 changed files with 82 additions and 83 deletions

View File

@@ -42,14 +42,14 @@ func WriteByteStream(ctx context.Context, stream streaming.Stream) io.WriteClose
default:
}
any, err := stream.Recv()
anyType, err := stream.Recv()
if err != nil {
if !errors.Is(err, io.EOF) && !errors.Is(err, context.Canceled) {
log.G(ctx).WithError(err).Error("send byte stream ended without EOF")
}
return
}
i, err := typeurl.UnmarshalAny(any)
i, err := typeurl.UnmarshalAny(anyType)
if err != nil {
log.G(ctx).WithError(err).Error("failed to unmarshal stream object")
continue
@@ -102,19 +102,19 @@ func (wbs *writeByteStream) Write(p []byte) (n int, err error) {
max = remaining
}
// TODO: continue
//remaining = remaining - int32(n)
// remaining = remaining - int32(n)
data := &transferapi.Data{
Data: p[:max],
}
var any typeurl.Any
any, err = typeurl.MarshalAny(data)
var anyType typeurl.Any
anyType, err = typeurl.MarshalAny(data)
if err != nil {
log.G(wbs.ctx).WithError(err).Errorf("failed to marshal data for send")
// TODO: Send error message on stream before close to allow remote side to return error
return
}
if err = wbs.stream.Send(any); err != nil {
if err = wbs.stream.Send(anyType); err != nil {
log.G(wbs.ctx).WithError(err).Errorf("send failed")
return
}