wailsapp/wails · error
use ShowAndGetResults for open multiple files dialog
Error message
use ShowAndGetResults for open multiple files dialog
What it means
ShowAndGetResult() on the single-select file-open dialog panics if the dialog was created as a multi-select dialog (FOS_ALLOWMULTISELECT). The library deliberately panics because calling the wrong pairing is a programming error by the developer using the API, not a runtime condition.
Source
Thrown at v2/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
- Call ShowAndGetResults() (plural) on multi-select dialogs
- If single-file selection is intended, create the dialog without the multiselect option
Example fix
// before dialog, _ := cfd.NewDialog(cfd.ForceFilePicker) // multiselect set elsewhere result, err := dialog.ShowAndGetResult() // panics // after results, err := dialog.ShowAndGetResults() // returns []string
Defensive patterns
Strategy: type-guard
Validate before calling
// know your dialog mode at creation time and store it
multi := false // set true only when multiselect was configured
if multi { paths, err := dialog.ShowAndGetResults() } else { path, err := dialog.ShowAndGetResult() } Type guard
// use the interface the library gives you: MultiFileDialog only exposes the plural APIs
func openFiles(d cfd.MultiFileDialog) ([]string, error) {
return d.ShowAndGetResults()
} Prevention
- Keep dialog variables typed as cfd.Dialog or cfd.MultiFileDialog, never the concrete type
- Wrap dialog usage in small helpers named OpenFile / OpenFiles so pairing is fixed in one place
When it happens
Trigger: Creating the dialog via the multi-select constructor/path and then calling ShowAndGetResult() instead of ShowAndGetResults().
Common situations: Copy-pasting single-file dialog sample code onto a multi-select dialog, or refactoring a dialog from single to multi selection without updating the call site.
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/b9d9588e4edafd3b.
Report an issue: GitHub.