Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Optimising the code by fixing var-declaration, indent-error-flow, increment-decrement, superfluous-else" #4

Merged
merged 1 commit into from
Aug 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions cmd/protoc-gen-go-grpc/grpc.go
Original file line number Diff line number Diff line change
@@ -347,12 +347,11 @@ func clientStreamInterface(g *protogen.GeneratedFile, method *protogen.Method) s
typeParam := g.QualifiedGoIdent(method.Input.GoIdent) + ", " + g.QualifiedGoIdent(method.Output.GoIdent)
if method.Desc.IsStreamingClient() && method.Desc.IsStreamingServer() {
return g.QualifiedGoIdent(grpcPackage.Ident("BidiStreamingClient")) + "[" + typeParam + "]"
}
if method.Desc.IsStreamingClient() {
} else if method.Desc.IsStreamingClient() {
return g.QualifiedGoIdent(grpcPackage.Ident("ClientStreamingClient")) + "[" + typeParam + "]"
} else { // i.e. if method.Desc.IsStreamingServer()
return g.QualifiedGoIdent(grpcPackage.Ident("ServerStreamingClient")) + "[" + g.QualifiedGoIdent(method.Output.GoIdent) + "]"
}
return g.QualifiedGoIdent(grpcPackage.Ident("ServerStreamingClient")) + "[" + g.QualifiedGoIdent(method.Output.GoIdent) + "]"

}

func genClientMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, method *protogen.Method, index int) {
@@ -515,11 +514,11 @@ func serverStreamInterface(g *protogen.GeneratedFile, method *protogen.Method) s
typeParam := g.QualifiedGoIdent(method.Input.GoIdent) + ", " + g.QualifiedGoIdent(method.Output.GoIdent)
if method.Desc.IsStreamingClient() && method.Desc.IsStreamingServer() {
return g.QualifiedGoIdent(grpcPackage.Ident("BidiStreamingServer")) + "[" + typeParam + "]"
}
if method.Desc.IsStreamingClient() {
} else if method.Desc.IsStreamingClient() {
return g.QualifiedGoIdent(grpcPackage.Ident("ClientStreamingServer")) + "[" + typeParam + "]"
} else { // i.e. if method.Desc.IsStreamingServer()
return g.QualifiedGoIdent(grpcPackage.Ident("ServerStreamingServer")) + "[" + g.QualifiedGoIdent(method.Output.GoIdent) + "]"
}
return g.QualifiedGoIdent(grpcPackage.Ident("ServerStreamingServer")) + "[" + g.QualifiedGoIdent(method.Output.GoIdent) + "]"
}

func genServerMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, method *protogen.Method, hnameFuncNameFormatter func(string) string) string {
2 changes: 1 addition & 1 deletion examples/features/flow_control/client/main.go
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ import (

var addr = flag.String("addr", "localhost:50052", "the address to connect to")

var payload = string(make([]byte, 8*1024)) // 8KB
var payload string = string(make([]byte, 8*1024)) // 8KB

func main() {
flag.Parse()
2 changes: 1 addition & 1 deletion examples/features/flow_control/server/main.go
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ import (

var port = flag.Int("port", 50052, "port number")

var payload = string(make([]byte, 8*1024)) // 8KB
var payload string = string(make([]byte, 8*1024)) // 8KB

// server is used to implement EchoServer.
type server struct {
2 changes: 1 addition & 1 deletion internal/channelz/funcs.go
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ var (
// outside this package except by tests.
IDGen IDGenerator

db = newChannelMap()
db *channelMap = newChannelMap()
// EntriesPerPage defines the number of channelz entries to be shown on a web page.
EntriesPerPage = 50
curState int32
4 changes: 2 additions & 2 deletions internal/internal.go
Original file line number Diff line number Diff line change
@@ -183,7 +183,7 @@ var (

// GRPCResolverSchemeExtraMetadata determines when gRPC will add extra
// metadata to RPCs.
GRPCResolverSchemeExtraMetadata = "xds"
GRPCResolverSchemeExtraMetadata string = "xds"

// EnterIdleModeForTesting gets the ClientConn to enter IDLE mode.
EnterIdleModeForTesting any // func(*grpc.ClientConn)
@@ -203,7 +203,7 @@ var (

// UserSetDefaultScheme is set to true if the user has overridden the
// default resolver scheme.
UserSetDefaultScheme = false
UserSetDefaultScheme bool = false

// ShuffleAddressListForTesting pseudo-randomizes the order of addresses. n
// is the number of elements. swap swaps the elements with indexes i and j.
6 changes: 4 additions & 2 deletions internal/transport/http2_client.go
Original file line number Diff line number Diff line change
@@ -1642,9 +1642,11 @@ func (t *http2Client) reader(errCh chan<- error) {
t.closeStream(s, status.Error(code, msg), true, http2.ErrCodeProtocol, status.New(code, msg), nil, false)
}
continue
} else {
// Transport error.
t.Close(connectionErrorf(true, err, "error reading from server: %v", err))
return
}
t.Close(connectionErrorf(true, err, "error reading from server: %v", err))
return
}
switch frame := frame.(type) {
case *http2.MetaHeadersFrame:
2 changes: 1 addition & 1 deletion internal/transport/http_util.go
Original file line number Diff line number Diff line change
@@ -389,7 +389,7 @@ type framer struct {
fr *http2.Framer
}

var writeBufferPoolMap = make(map[int]*sync.Pool)
var writeBufferPoolMap map[int]*sync.Pool = make(map[int]*sync.Pool)
var writeBufferMutex sync.Mutex

func newFramer(conn net.Conn, writeBufferSize, readBufferSize int, sharedWriteBuffer bool, maxHeaderListSize uint32) *framer {
6 changes: 3 additions & 3 deletions profiling/cmd/remote.go
Original file line number Diff line number Diff line change
@@ -90,9 +90,9 @@ func remoteCommand() error {

if *flagEnableProfiling || *flagDisableProfiling {
return setEnabled(ctx, c, *flagEnableProfiling)
}
if *flagRetrieveSnapshot {
} else if *flagRetrieveSnapshot {
return retrieveSnapshot(ctx, c, *flagSnapshot)
} else {
return fmt.Errorf("what should I do with the remote target?")
}
return fmt.Errorf("what should I do with the remote target?")
}
4 changes: 2 additions & 2 deletions stats/opentelemetry/internal/testutils/testutils.go
Original file line number Diff line number Diff line change
@@ -131,8 +131,8 @@ func createBucketCounts(recordingPoints []float64, bounds []float64) []uint64 {
continue
}
for recordingPoints[recordingPointIndex] <= bound {
bucketCount++
recordingPointIndex++
bucketCount += 1
recordingPointIndex += 1
if recordingPointIndex >= len(recordingPoints) {
break
}