wailsapp/wails · error
use ShowAndGetResults for open multiple files dialog
Error message
use ShowAndGetResults for open multiple files dialog
What it means
The v3 copy of go-common-file-dialog: ShowAndGetResult() panics if the open dialog was created with multi-select enabled (FOS_ALLOWMULTISELECT), because the single-result API cannot represent multiple selections. The panic is intentional, flagging developer misuse of the single/multi API pairing.
Source
Thrown at v3/internal/go-common-file-dialog/cfd/iFileOpenDialog.go:53
}
}
func (fileOpenDialog *iFileOpenDialog) Show() error {
return fileOpenDialog.vtbl.show(unsafe.Pointer(fileOpenDialog), fileOpenDialog.parentWindowHandle)
}
func (fileOpenDialog *iFileOpenDialog) SetParentWindowHandle(hwnd uintptr) {
fileOpenDialog.parentWindowHandle = hwnd
}
func (fileOpenDialog *iFileOpenDialog) ShowAndGetResult() (string, error) {
isMultiselect, err := fileOpenDialog.isMultiselect()
if err != nil {
return "", err
}
if isMultiselect {
// We should panic as this error is caused by the developer using the library
panic("use ShowAndGetResults for open multiple files dialog")
}
if err := fileOpenDialog.Show(); err != nil {
return "", err
}
return fileOpenDialog.GetResult()
}
func (fileOpenDialog *iFileOpenDialog) ShowAndGetResults() ([]string, error) {
isMultiselect, err := fileOpenDialog.isMultiselect()
if err != nil {
return nil, err
}
if !isMultiselect {
// We should panic as this error is caused by the developer using the library
panic("use ShowAndGetResult for open single file dialog")
}
if err := fileOpenDialog.Show(); err != nil {
return nil, errView on GitHub (pinned to 0e754b1b40)
Solutions
- Use ShowAndGetResults() (plural) for multi-select dialogs
- Create the dialog without multiselect if only one file is wanted
Example fix
// before path, err := dialog.ShowAndGetResult() // multiselect dialog: panics // after paths, err := dialog.ShowAndGetResults()
Defensive patterns
Strategy: type-guard
Validate before calling
// track dialog mode where you create it and branch once
if multiSelect {
paths, err := dialog.ShowAndGetResults()
} else {
path, err := dialog.ShowAndGetResult()
} Type guard
func openFilesV3(d cfd.MultiFileDialog) ([]string, error) {
return d.ShowAndGetResults()
} Prevention
- Type dialog variables as cfd.Dialog or cfd.MultiFileDialog in v3 too
- Centralize dialog calls in OpenFile/OpenFiles wrappers per mode
When it happens
Trigger: Building a multi-select FileOpen dialog in a Wails v3 app and calling ShowAndGetResult() (singular).
Common situations: Porting v2 dialog code into v3, or writing a generic 'pick file(s)' helper that always uses the singular call.
Related errors
- use ShowAndGetResult for open single file dialog
- use GetResults for open multiple files dialog
- use GetResult for open single file dialog
- use ShowAndGetResults for open multiple files dialog
- use ShowAndGetResult for open single file dialog
AI-assisted analysis of wailsapp/wails@0e754b1b40 (2026-08-15).
Data as JSON: /api/errors/4ea5c62ec07f369b.
Report an issue: GitHub.