mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-08 07:21:46 +08:00

* Add some clarifying comments * Remove special handling of window parameters * Improve internal method exclusion * Add test for internal method exclusion * Remove useless blank field from app options This is a leftover from an older version of the static analyser. It should have been removed long ago. * Remove redundant godebug setting gotypesalias=1 is the default starting with go1.23 * Use new range for syntax to simplify code * Remove generator dependency on github.com/samber/lo * Ensure generator testing tasks do not use the test cache * Rename cyclic types test * Test for cyclic imports * Fix import cycle between model files * Sort class aliases after their aliased class * Test class aliases * Fix length of default value for array types * Test array initialization * Add changelog * Update changelog * Fix contrived marking technique in model sorting algorithm * Update binding example * Update test data --------- Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
95 lines
1.8 KiB
Go
95 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
_ "embed"
|
|
"log"
|
|
|
|
"github.com/wailsapp/wails/v3/pkg/application"
|
|
)
|
|
|
|
// GreetService is great
|
|
type GreetService int
|
|
|
|
// A nice type Alias.
|
|
type Alias = int
|
|
|
|
// A class alias.
|
|
type AliasedPerson = Person
|
|
|
|
// An empty struct alias.
|
|
type EmptyAliasStruct = struct{}
|
|
|
|
// A struct alias.
|
|
// This should be rendered as a typedef or interface in every mode.
|
|
type AliasStruct = struct {
|
|
// A field with a comment.
|
|
Foo []int
|
|
Bar, Baz string `json:",omitempty"` // Definitely not Foo.
|
|
|
|
Other OtherAliasStruct // A nested alias struct.
|
|
}
|
|
|
|
// Another struct alias.
|
|
type OtherAliasStruct = struct {
|
|
NoMoreIdeas []rune
|
|
}
|
|
|
|
// An empty struct.
|
|
type EmptyStruct struct{}
|
|
|
|
// A non-generic struct containing an alias.
|
|
type Person struct {
|
|
Name string // The Person's name.
|
|
AliasedField Alias // A random alias field.
|
|
}
|
|
|
|
// A generic struct containing an alias.
|
|
type GenericPerson[T any] struct {
|
|
Name T
|
|
AliasedField Alias
|
|
}
|
|
|
|
// Another class alias, but ordered after its aliased class.
|
|
type StrangelyAliasedPerson = Person
|
|
|
|
// Get someone.
|
|
func (GreetService) Get(aliasValue Alias) Person {
|
|
return Person{"hello", aliasValue}
|
|
}
|
|
|
|
// Get someone quite different.
|
|
func (GreetService) GetButDifferent() GenericPerson[bool] {
|
|
return GenericPerson[bool]{true, 13}
|
|
}
|
|
|
|
// Apparently, aliases are all the rage right now.
|
|
func (GreetService) GetButAliased(p AliasedPerson) StrangelyAliasedPerson {
|
|
return p
|
|
}
|
|
|
|
// Greet a lot of unusual things.
|
|
func (GreetService) Greet(EmptyAliasStruct, EmptyStruct) AliasStruct {
|
|
return AliasStruct{}
|
|
}
|
|
|
|
func NewGreetService() application.Service {
|
|
return application.NewService(new(GreetService))
|
|
}
|
|
|
|
func main() {
|
|
app := application.New(application.Options{
|
|
Services: []application.Service{
|
|
NewGreetService(),
|
|
},
|
|
})
|
|
|
|
app.NewWebviewWindow()
|
|
|
|
err := app.Run()
|
|
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
}
|