Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It now includes more syntax, such as type sets. Plus, we also check that we error on Go 1.17 and older.
- Loading branch information
Showing
1 changed file
with
36 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,53 @@ | ||
[!go1.18] skip 'type parameters require Go 1.18 or later' | ||
[go1.18] gofumpt foo.go | ||
[!go1.18] ! gofumpt foo.go | ||
|
||
gofumpt foo.go | ||
cmp stdout foo.go.golden | ||
[go1.18] cmp stdout foo.go.golden | ||
[!go1.18] stderr 'foo.go:.*expected' | ||
|
||
-- go.mod -- | ||
module test | ||
|
||
go 1.18 | ||
-- foo.go -- | ||
package main | ||
package p | ||
|
||
func Foo[ A, B any](x A, y B) {} | ||
func Foo[A, B any](x A, y B) {} | ||
|
||
type Vector[T any] []T | ||
|
||
var v Vector[int ] | ||
|
||
type PredeclaredSignedInteger interface { | ||
int | int8 | int16 | int32 | int64 | ||
} | ||
|
||
type StringableSignedInteger interface { | ||
~int | ~int8 | ~int16 | ~int32 | ~int64 | ||
String() string | ||
|
||
} | ||
|
||
func main() { | ||
func Caller() { | ||
Foo[int,int](1,2) | ||
} | ||
-- foo.go.golden -- | ||
package main | ||
package p | ||
|
||
func Foo[A, B any](x A, y B) {} | ||
|
||
func main() { | ||
type Vector[T any] []T | ||
|
||
var v Vector[int] | ||
|
||
type PredeclaredSignedInteger interface { | ||
int | int8 | int16 | int32 | int64 | ||
} | ||
|
||
type StringableSignedInteger interface { | ||
~int | ~int8 | ~int16 | ~int32 | ~int64 | ||
String() string | ||
} | ||
|
||
func Caller() { | ||
Foo[int, int](1, 2) | ||
} |