wailsapp/wails · error
use ShowAndGetResult for open single file dialog
Error message
use ShowAndGetResult for open single file dialog
What it means
ShowAndGetResults() (plural) panics when the dialog was NOT created as a multi-select dialog. The single-select COM API path cannot return multiple results, so mixing them is treated as a developer programming error and panics immediately.
Source
Thrown at v2/internal/go-common-file-dialog/cfd/iFileOpenDialog.go:68
}
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, err
}
return fileOpenDialog.GetResults()
}
func (fileOpenDialog *iFileOpenDialog) SetTitle(title string) error {
return fileOpenDialog.vtbl.setTitle(unsafe.Pointer(fileOpenDialog), title)
}
func (fileOpenDialog *iFileOpenDialog) GetResult() (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 libraryView on GitHub (pinned to 0e754b1b40)
Solutions
- Call ShowAndGetResult() (singular) on single-select dialogs
- If multi-selection is intended, enable the multiselect option when creating the dialog
Example fix
// before results, err := dialog.ShowAndGetResults() // single dialog: panics // after result, err := dialog.ShowAndGetResult() // returns string
Defensive patterns
Strategy: type-guard
Validate before calling
// single-select dialog: use the singular helper only
if !multi { path, err := dialog.ShowAndGetResult() } else { paths, err := dialog.ShowAndGetResults() } Type guard
func openOne(d cfd.Dialog) (string, error) {
return d.ShowAndGetResult() // Dialog interface cannot even see plural methods
} Prevention
- Use ShowAndGetResult()/ShowAndGetResults() helpers instead of manual Show + Get pairings
- Let the Dialog vs MultiFileDialog interfaces enforce the pairing at compile time
When it happens
Trigger: Creating a default/single-select open dialog and calling ShowAndGetResults() instead of ShowAndGetResult().
Common situations: Reusing multi-select code from another feature for a plain 'open file' dialog, or copy-paste between the two code paths.
Related errors
- use ShowAndGetResults for open multiple files 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/03cfc9e6092d609c.
Report an issue: GitHub.