mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-08 04:10:31 +08:00

* Rename predicates source file * Overhaul and document type predicates * Fix model collection logic for named types * Fix map key type rendering * Fix map creation code * Fix rendering of structs that implement marshaler interfaces * Fix type cycle detection to take type args into account * Fix enum and typeparam field initialisation * Improve unsupported type warnings * Remove internal models file * Deduplicate template code * Accept generic aliases in static analyser * Support new `encoding/json` flag `omitzero` * Handle special cases when rendering generic aliases * Update npm test dependencies * Test class aliases and implicit private dependencies * Test marshaler combinations * Test map key types * Remove bad map keys from unrelated tests * Test service discovery through generic aliases * Test generic aliases * Test warning messages * Disable go1.24 tests * Update changelog * Restore rendering of injected lines in index file * Test directives * Add wails:ignore directive * Fix typo * Move injections to the bottom of service files * Handle errors from closing files * Do not emit messages when services define only lifecycle methods * Add internal directive for services and models * Update changelog * Fix error in service templates * Test internal directive on services/models * Fix error in index template * Base testdata updates * Testdata for class aliases and implicit private dependencies * Testdata for marshaler combinations * Testdata for map key types * Testdata for bad map key fixes * Add weakly typed enums aka alias constants * Testdata for enum and typeparam field fixes * Testdata for generic aliases * Testdata for warning messages * Testdata for directives * Testdata for weakly typed enums * Update binding example * Update services example * Remove go1.24 testdata * Update cli doc * Fix analyser tests * Fix windows tests... hopefully * go mod tidy on examples * Update bindings guide --------- Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
206 lines
3.8 KiB
Go
206 lines
3.8 KiB
Go
package main
|
|
|
|
import (
|
|
_ "embed"
|
|
"log"
|
|
"strings"
|
|
|
|
"github.com/wailsapp/wails/v3/pkg/application"
|
|
)
|
|
|
|
type Person struct {
|
|
Name string
|
|
Parent *Person
|
|
Details struct {
|
|
Age int
|
|
Address struct {
|
|
Street string
|
|
}
|
|
}
|
|
}
|
|
|
|
// GreetService is great
|
|
type GreetService struct {
|
|
SomeVariable int
|
|
lowerCase string
|
|
}
|
|
|
|
// Greet someone
|
|
func (*GreetService) Greet(name string) string {
|
|
return "Hello " + name
|
|
}
|
|
|
|
func (*GreetService) NoInputsStringOut() string {
|
|
return "Hello"
|
|
}
|
|
|
|
func (*GreetService) StringArrayInputStringOut(in []string) string {
|
|
return strings.Join(in, ",")
|
|
}
|
|
|
|
func (*GreetService) StringArrayInputStringArrayOut(in []string) []string {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) StringArrayInputNamedOutput(in []string) (output []string) {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) StringArrayInputNamedOutputs(in []string) (output []string, err error) {
|
|
return in, nil
|
|
}
|
|
|
|
func (*GreetService) IntPointerInputNamedOutputs(in *int) (output *int, err error) {
|
|
return in, nil
|
|
}
|
|
|
|
func (*GreetService) UIntPointerInAndOutput(in *uint) *uint {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) UInt8PointerInAndOutput(in *uint8) *uint8 {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) UInt16PointerInAndOutput(in *uint16) *uint16 {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) UInt32PointerInAndOutput(in *uint32) *uint32 {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) UInt64PointerInAndOutput(in *uint64) *uint64 {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) IntPointerInAndOutput(in *int) *int {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) Int8PointerInAndOutput(in *int8) *int8 {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) Int16PointerInAndOutput(in *int16) *int16 {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) Int32PointerInAndOutput(in *int32) *int32 {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) Int64PointerInAndOutput(in *int64) *int64 {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) IntInIntOut(in int) int {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) Int8InIntOut(in int8) int8 {
|
|
return in
|
|
}
|
|
func (*GreetService) Int16InIntOut(in int16) int16 {
|
|
return in
|
|
}
|
|
func (*GreetService) Int32InIntOut(in int32) int32 {
|
|
return in
|
|
}
|
|
func (*GreetService) Int64InIntOut(in int64) int64 {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) UIntInUIntOut(in uint) uint {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) UInt8InUIntOut(in uint8) uint8 {
|
|
return in
|
|
}
|
|
func (*GreetService) UInt16InUIntOut(in uint16) uint16 {
|
|
return in
|
|
}
|
|
func (*GreetService) UInt32InUIntOut(in uint32) uint32 {
|
|
return in
|
|
}
|
|
func (*GreetService) UInt64InUIntOut(in uint64) uint64 {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) Float32InFloat32Out(in float32) float32 {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) Float64InFloat64Out(in float64) float64 {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) PointerFloat32InFloat32Out(in *float32) *float32 {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) PointerFloat64InFloat64Out(in *float64) *float64 {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) BoolInBoolOut(in bool) bool {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) PointerBoolInBoolOut(in *bool) *bool {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) PointerStringInStringOut(in *string) *string {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) StructPointerInputErrorOutput(in *Person) error {
|
|
return nil
|
|
}
|
|
|
|
func (*GreetService) StructInputStructOutput(in Person) Person {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) StructPointerInputStructPointerOutput(in *Person) *Person {
|
|
return in
|
|
}
|
|
|
|
func (*GreetService) MapIntInt(in map[int]int) {
|
|
}
|
|
|
|
func (*GreetService) PointerMapIntInt(in *map[int]int) {
|
|
}
|
|
|
|
func (*GreetService) MapIntIntPointer(in map[int]*int) {
|
|
}
|
|
|
|
func (*GreetService) MapIntSliceInt(in map[int][]int) {
|
|
}
|
|
|
|
func (*GreetService) MapIntSliceIntInMapIntSliceIntOut(in map[int][]int) (out map[int][]int) {
|
|
return nil
|
|
}
|
|
|
|
func (*GreetService) ArrayInt(in [4]int) {
|
|
}
|
|
|
|
func main() {
|
|
app := application.New(application.Options{
|
|
Services: []application.Service{
|
|
application.NewService(&GreetService{}),
|
|
},
|
|
})
|
|
|
|
app.NewWebviewWindow()
|
|
|
|
err := app.Run()
|
|
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
}
|