Skip to content

Instantly share code, notes, and snippets.

@sykesm
Created July 22, 2020 15:52
Show Gist options
  • Save sykesm/9e70bb092ed05f05068b8639c5ce33cb to your computer and use it in GitHub Desktop.
Save sykesm/9e70bb092ed05f05068b8639c5ce33cb to your computer and use it in GitHub Desktop.
errInvalidUTF8 is not a proto.Error
module proto-utf8
go 1.14
require (
github.com/golang/protobuf v1.4.2
google.golang.org/protobuf v1.25.0
)
package main
import (
"errors"
"log"
"proto-utf8/testproto"
"google.golang.org/protobuf/proto"
)
func main() {
message := &testproto.Message{
Str: string([]byte{200, 200, 200}),
}
_, err := proto.Marshal(message)
if err == nil {
log.Fatalf("expected marshal to fail")
}
if !errors.Is(err, proto.Error) {
log.Fatalf("expected %#v to be a proto.Error", err)
}
}
syntax = "proto3";
package testproto;
message Message {
string str = 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment