generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Go support for parametric types (#822)
``` 🐚 ~/dev/ftl $ ftl schema module time { data TimeRequest<T> { data T } data TimeResponse { time Time } // Time returns the current time. verb time(time.TimeRequest<String>) time.TimeResponse ingress ftl GET /time } ``` After modifying time to have a generic request and echo to use it: ``` 🐚 ~/dev/ftl $ ftl call echo.echo {"message":"Hello, anonymous!!! It is 2024-01-20 12:38:24.254176 +1100 AEDT!"} ```
- Loading branch information
1 parent
b7cbc0e
commit eb4827f
Showing
18 changed files
with
610 additions
and
206 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
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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package schema | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/alecthomas/assert/v2" | ||
) | ||
|
||
func TestMonomorphisation(t *testing.T) { | ||
data := &Data{ | ||
Name: "Data", | ||
TypeParameters: []*TypeParameter{{Name: "T"}}, | ||
Fields: []*Field{ | ||
{Name: "a", Type: &TypeParameter{Name: "T"}}, | ||
}, | ||
} | ||
actual, err := data.Monomorphise(&String{}) | ||
assert.NoError(t, err) | ||
expected := &Data{ | ||
Comments: []string{}, | ||
Name: "Data", | ||
Fields: []*Field{{Comments: []string{}, Name: "a", Type: &String{}}}, | ||
Metadata: []Metadata{}, | ||
} | ||
assert.Equal(t, expected, actual, assert.OmitEmpty()) | ||
} |
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
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
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
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
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
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
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
Oops, something went wrong.