mirror of
https://github.com/golang/go
synced 2024-11-11 21:10:21 -07:00
cb458c05a8
This is the same fix as CL 36126, but for the reverse case, function with shape params but passed no shape arg. The same conversion problem may occur in this case, see details explanation there. Fixes #51909 Fixes #51925 Change-Id: Ib0c1973c7511d85b4918a252c80060f1864180cf Reviewed-on: https://go-review.googlesource.com/c/go/+/395854 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
31 lines
591 B
Go
31 lines
591 B
Go
// compile
|
|
|
|
// Copyright 2022 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package main
|
|
|
|
type None struct{}
|
|
|
|
type Response interface {
|
|
send(ctx *struct{})
|
|
}
|
|
|
|
type HandlerFunc[Input any] func(Input) Response
|
|
|
|
func Operation[Input any](method, path string, h HandlerFunc[Input]) {
|
|
var input Input
|
|
h(input)
|
|
}
|
|
|
|
func Get[Body any](path string, h HandlerFunc[struct{ Body Body }]) {
|
|
Operation("GET", path, h)
|
|
}
|
|
|
|
func main() {
|
|
Get("/", func(req struct{ Body None }) Response {
|
|
return nil
|
|
})
|
|
}
|