Last active
December 30, 2021 18:51
-
-
Save matthewmueller/df2f97950bc53d2e62c673b49a213101 to your computer and use it in GitHub Desktop.
Experimenting with generics as a way of annotating fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You can edit this code! | |
// Click here and start typing. | |
package main | |
import ( | |
"io" | |
) | |
func main() { | |
fmt.Println(Show(Query[int]{10})) | |
} | |
type Query[T any] struct{ t T } | |
func Show(q Query[int]) int { | |
return q.t | |
} | |
type Body[T any] struct{} | |
type Request struct { | |
gt Query[int] | |
} | |
func Show2(r *Request, body Body[io.Reader]) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment