Created
July 22, 2020 15:52
-
-
Save sykesm/9e70bb092ed05f05068b8639c5ce33cb to your computer and use it in GitHub Desktop.
errInvalidUTF8 is not a proto.Error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module proto-utf8 | |
go 1.14 | |
require ( | |
github.com/golang/protobuf v1.4.2 | |
google.golang.org/protobuf v1.25.0 | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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