wails icon indicating copy to clipboard operation
wails copied to clipboard

Slice of array causes `wails generate module` to fail

Open thetechpanda opened this issue 10 months ago • 0 comments

Description

wails generate module fails when a slice of array is part of an exported struct.

This bug could be related to #2323, #2303 too.

To Reproduce

  1. wails init -n test-bug
  2. cd test-bug
  3. go get github.com/google/uuid
  4. Add the following lines to app.go and add "github.com/google/uuid" to the imports
/* Copy the following code to your app.go file */
/* Add "github.com/google/uuid" to the imports */

type Works struct {
	Bytes   [1]byte   `json:"bytes" validate:""`
	Strings [1]string `json:"strings" validate:""`
	UUID    uuid.UUID `json:"uuid" validate:""`
}

type DoesNotWork struct {
	Bytes   [][1]byte   `json:"bytes" validate:""`
	Strings [][1]string `json:"strings" validate:""`
	UUIDs   []uuid.UUID `json:"uuids" validate:""`
}

// modules are generated
func (a *App) Works() Works {
	return Works{}
}

// modules are not generated
func (a *App) DoesNotWork() DoesNotWork {
	return DoesNotWork{}
}
  1. go mod tidy
  2. wails generate module

The following are obtained by having only one of DoesNotWork struct fields at the time.

DoesNotWork.Bytes

2024/04/28 14:15:04 Error: cannot find type for array (bytes/)

DoesNotWork.Strings

2024/04/28 14:15:46 Error: cannot find type for array (strings/)

DoesNotWork.UUIDs

2024/04/28 14:16:21 Error: cannot find type for array (uuids/UUID)

Expected behaviour

modules are generated

Screenshots

No response

Attempted Fixes

No response

System Details

Wails Doctor          
                                

                                                                                                                                                                                                                                                   
# Wails
Version | v2.8.1

# System
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| OS           | MacOS                                                                                                                       |
| Version      | 14.4.1                                                                                                                      |
| ID           | 23E224                                                                                                                      |
| Go Version   | go1.22.0                                                                                                                    |
| Platform     | darwin                                                                                                                      |
| Architecture | arm64                                                                                                                       |
| CPU          | Apple M2 Max                                                                                                                |
| GPU          | Chipset Model: Apple M2 Max Type: GPU Bus: Built-In Total Number of Cores: 30 Vendor: Apple (0x106b) Metal Support: Metal 3 |
| Memory       | 32GB                                                                                                                        |
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌───────────────────────────────────────────────────────────────────────┐
| Dependency                | Package Name | Status    | Version        |
| Xcode command line tools  | N/A          | Installed | 2406           |
| Nodejs                    | N/A          | Installed | 21.6.1         |
| npm                       | N/A          | Installed | 10.2.4         |
| *Xcode                    | N/A          | Installed | 15.3 (15E204a) |
| *upx                      | N/A          | Available |                |
| *nsis                     | N/A          | Available |                |
└─────────────────────── * - Optional Dependency ───────────────────────┘

# Diagnosis
Optional package(s) installation details: 
  - upx : Available at https://upx.github.io/
  - nsis : More info at https://wails.io/docs/guides/windows-installer/

 SUCCESS  Your system is ready for Wails development!

 ♥   If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony

Additional context

Discovered while migrating UUIDs in a personal project from string to uuid.UUID.

thetechpanda avatar Apr 28 '24 04:04 thetechpanda