Skip to content

Commit 4a5ff3f

Browse files
Copilotpjbgf
andauthored
fix: move NewBackend after Handler declaration to satisfy funcorder lint rule
Agent-Logs-Url: https://github.com/go-git/cli/sessions/04418706-009d-4bb7-be81-ad46f84db2ae Co-authored-by: pjbgf <5452977+pjbgf@users.noreply.github.com>
1 parent dc00876 commit 4a5ff3f

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

server/git/server.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,29 @@ var ErrServerClosed = errors.New("server closed")
2828
// DefaultBackend is the default global Git transport server handler.
2929
var DefaultBackend Handler = NewBackend(nil)
3030

31+
// ServerContextKey is the context key used to store the server in the context.
32+
var ServerContextKey = &contextKey{"git-server"}
33+
34+
// Handler is the interface that handles TCP requests for the Git protocol.
35+
type Handler interface {
36+
// ServeTCP handles a TCP connection for the Git protocol.
37+
ServeTCP(ctx context.Context, c io.ReadWriteCloser, req *packp.GitProtoRequest)
38+
}
39+
3140
// NewBackend creates a [Handler] backed by the given [transport.Loader].
3241
// If loader is nil, [transport.DefaultLoader] is used.
3342
func NewBackend(loader transport.Loader) Handler {
3443
return &backendHandler{b: backend.New(loader)}
3544
}
3645

46+
// HandlerFunc is a function that implements the Handler interface.
47+
type HandlerFunc func(ctx context.Context, c io.ReadWriteCloser, req *packp.GitProtoRequest)
48+
49+
// ServeTCP implements the Handler interface.
50+
func (f HandlerFunc) ServeTCP(ctx context.Context, c io.ReadWriteCloser, req *packp.GitProtoRequest) {
51+
f(ctx, c, req)
52+
}
53+
3754
// backendHandler wraps a [backend.Backend] to implement the [Handler] interface.
3855
type backendHandler struct {
3956
b *backend.Backend
@@ -47,23 +64,6 @@ func (bh *backendHandler) ServeTCP(ctx context.Context, c io.ReadWriteCloser, re
4764
}
4865
}
4966

50-
// ServerContextKey is the context key used to store the server in the context.
51-
var ServerContextKey = &contextKey{"git-server"}
52-
53-
// Handler is the interface that handles TCP requests for the Git protocol.
54-
type Handler interface {
55-
// ServeTCP handles a TCP connection for the Git protocol.
56-
ServeTCP(ctx context.Context, c io.ReadWriteCloser, req *packp.GitProtoRequest)
57-
}
58-
59-
// HandlerFunc is a function that implements the Handler interface.
60-
type HandlerFunc func(ctx context.Context, c io.ReadWriteCloser, req *packp.GitProtoRequest)
61-
62-
// ServeTCP implements the Handler interface.
63-
func (f HandlerFunc) ServeTCP(ctx context.Context, c io.ReadWriteCloser, req *packp.GitProtoRequest) {
64-
f(ctx, c, req)
65-
}
66-
6767
// Server is a TCP server that handles Git protocol requests.
6868
type Server struct {
6969
// Addr is the address to listen on. If empty, it defaults to ":9418".

0 commit comments

Comments
 (0)