proto: move T->*T wrappers from internal/scalar to proto
Usage of these is pervasive in code which works with proto2, and proto2
will be with us for a long, long time to come. Move them to the proto
package.
Change-Id: I1b2e57429fd5a8f107a848a4492d20c27f304bd7
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/185543
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/compiler/protogen/protogen.go b/compiler/protogen/protogen.go
index 0191e09..6f6be12 100644
--- a/compiler/protogen/protogen.go
+++ b/compiler/protogen/protogen.go
@@ -30,7 +30,6 @@
"google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/internal/fieldnum"
- "google.golang.org/protobuf/internal/scalar"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protodesc"
"google.golang.org/protobuf/reflect/protoreflect"
@@ -340,7 +339,7 @@
func (gen *Plugin) Response() *pluginpb.CodeGeneratorResponse {
resp := &pluginpb.CodeGeneratorResponse{}
if gen.err != nil {
- resp.Error = scalar.String(gen.err.Error())
+ resp.Error = proto.String(gen.err.Error())
return resp
}
for _, g := range gen.genFiles {
@@ -350,23 +349,23 @@
content, err := g.Content()
if err != nil {
return &pluginpb.CodeGeneratorResponse{
- Error: scalar.String(err.Error()),
+ Error: proto.String(err.Error()),
}
}
resp.File = append(resp.File, &pluginpb.CodeGeneratorResponse_File{
- Name: scalar.String(g.filename),
- Content: scalar.String(string(content)),
+ Name: proto.String(g.filename),
+ Content: proto.String(string(content)),
})
if gen.annotateCode && strings.HasSuffix(g.filename, ".go") {
meta, err := g.metaFile(content)
if err != nil {
return &pluginpb.CodeGeneratorResponse{
- Error: scalar.String(err.Error()),
+ Error: proto.String(err.Error()),
}
}
resp.File = append(resp.File, &pluginpb.CodeGeneratorResponse_File{
- Name: scalar.String(g.filename + ".meta"),
- Content: scalar.String(meta),
+ Name: proto.String(g.filename + ".meta"),
+ Content: proto.String(meta),
})
}
}
@@ -1061,10 +1060,10 @@
seenAnnotations[s] = true
for _, loc := range g.annotations[s] {
info.Annotation = append(info.Annotation, &descriptorpb.GeneratedCodeInfo_Annotation{
- SourceFile: scalar.String(loc.SourceFile),
+ SourceFile: proto.String(loc.SourceFile),
Path: loc.Path,
- Begin: scalar.Int32(int32(fset.Position(ident.Pos()).Offset)),
- End: scalar.Int32(int32(fset.Position(ident.End()).Offset)),
+ Begin: proto.Int32(int32(fset.Position(ident.Pos()).Offset)),
+ End: proto.Int32(int32(fset.Position(ident.End()).Offset)),
})
}
}