wailsapp/wails · error
use GetResult for open single file dialog
Error message
use GetResult for open single file dialog
What it means
The v3 copy of go-common-file-dialog: GetResults() (plural) panics on single-select dialogs. The doc comment states this method is meant to be reachable only when multi-select was requested; the MultiFileDialog interface exposes it while the single Dialog interface does not, so hitting it means the concrete type was used directly or the interface contract was bypassed.
Solutions
- Use GetResult() (singular) on single-select dialogs
- Keep variables typed as cfd.Dialog vs cfd.MultiFileDialog so the compiler prevents the wrong call
Example fix
// before var d cfd.MultiFileDialog = any(singleDialog).(cfd.MultiFileDialog) paths, _ := d.GetResults() // panics // after var d cfd.Dialog = singleDialog path, _ := d.ShowAndGetResult()
Defensive patterns
Strategy: type-guard
Validate before calling
// single dialog: singular accessor path, err := dialog.GetResult()
Type guard
func resultOfV3(d cfd.Dialog) (string, error) {
return d.GetResult() // plural methods not visible on Dialog
} Prevention
- Never bypass the Dialog/MultiFileDialog interface split via assertions
- Return narrow interfaces from dialog factories
When it happens
Trigger: Type-asserting or directly holding iFileOpenDialog / using MultiFileDialog-typed variables for a dialog created without multiselect, then calling GetResults().
Common situations: Generic dialog wrapper functions parameterized over the concrete dialog type, bypassing the interface-level protection the library normally provides.
Related errors
- use GetResults for open multiple files dialog
- use ShowAndGetResult for open single file dialog
- use ShowAndGetResults for open multiple files dialog
- use GetResult for open single file dialog
- use GetResults for open multiple files dialog
AI-assisted analysis of wailsapp/wails@0e754b1b40 (2026-08-15).
Data as JSON: /api/errors/db6ed89f0711a777.
Report an issue: GitHub.
Appendix: source
Thrown at v3/internal/go-common-file-dialog/cfd/iFileOpenDialog.go:121
func (fileOpenDialog *iFileOpenDialog) SetFileFilters(filter []FileFilter) error {
return fileOpenDialog.vtbl.setFileTypes(unsafe.Pointer(fileOpenDialog), filter)
}
func (fileOpenDialog *iFileOpenDialog) SetRole(role string) error {
return fileOpenDialog.vtbl.setClientGuid(unsafe.Pointer(fileOpenDialog), StringToUUID(role))
}
// This should only be callable when the user asks for a multi select because
// otherwise they will be given the Dialog interface which does not expose this function.
func (fileOpenDialog *iFileOpenDialog) GetResults() ([]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 GetResult for open single file dialog")
}
return fileOpenDialog.vtbl.getResultsStrings(unsafe.Pointer(fileOpenDialog))
}
func (fileOpenDialog *iFileOpenDialog) SetDefaultExtension(defaultExtension string) error {
return fileOpenDialog.vtbl.setDefaultExtension(unsafe.Pointer(fileOpenDialog), defaultExtension)
}
func (fileOpenDialog *iFileOpenDialog) SetFileName(initialFileName string) error {
return fileOpenDialog.vtbl.setFileName(unsafe.Pointer(fileOpenDialog), initialFileName)
}
func (fileOpenDialog *iFileOpenDialog) SetSelectedFileFilterIndex(index uint) error {
return fileOpenDialog.vtbl.setSelectedFileFilterIndex(unsafe.Pointer(fileOpenDialog), index)
}
func (fileOpenDialog *iFileOpenDialog) setPickFolders(pickFolders bool) error {
const FosPickfolders = 0x20View on GitHub (pinned to 0e754b1b40)