go-proto-zap-marshaler
go-proto-zap-marshaler copied to clipboard
Inconsistent import order.
Hi, thanks for the project.
I noticed that when repeatedly running protoc
with zap, the import order in the go code changes, despite nothing changing in the source proto files. It would be nice if it were always generating in the same order that gofmt sets.
For example with this small proto file.
main.proto
syntax = "proto3";
package test;
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
If I run it twice, I get a diff like this.
- _ "google.golang.org/protobuf/types/known/structpb"
- _ "google.golang.org/protobuf/types/known/timestamppb"
+ _ "google.golang.org/protobuf/types/known/timestamppb"
+ _ "google.golang.org/protobuf/types/known/structpb"
A full log is below.
$ protoc --zap-marshaler_out=. main.proto && cat main.zap.go
main.proto:5:1: warning: Import google/protobuf/struct.proto is unused.
main.proto:6:1: warning: Import google/protobuf/timestamp.proto is unused.
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: main.proto
package test
import (
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
_ "google.golang.org/protobuf/types/known/timestamppb" <<<<---- timestamp first
_ "google.golang.org/protobuf/types/known/structpb" <<<<---- structpb second
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
$ protoc --zap-marshaler_out=. main.proto && cat main.zap.go
main.proto:5:1: warning: Import google/protobuf/struct.proto is unused.
main.proto:6:1: warning: Import google/protobuf/timestamp.proto is unused.
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: main.proto
package test
import (
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
_ "google.golang.org/protobuf/types/known/structpb" <<<<---- structpb first
_ "google.golang.org/protobuf/types/known/timestamppb" <<<<---- timestamp second
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf