{"record":{"id":"b9d9588e4edafd3b","repo":"wailsapp/wails","slug":"use-showandgetresults-for-open-multiple-files-dial","errorCode":null,"errorMessage":"use ShowAndGetResults for open multiple files dialog","messagePattern":"use ShowAndGetResults for open multiple files dialog","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v2/internal/go-common-file-dialog/cfd/iFileOpenDialog.go","lineNumber":53,"sourceCode":"\t}\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) Show() error {\n\treturn fileOpenDialog.vtbl.show(unsafe.Pointer(fileOpenDialog), fileOpenDialog.parentWindowHandle)\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) SetParentWindowHandle(hwnd uintptr) {\n\tfileOpenDialog.parentWindowHandle = hwnd\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) ShowAndGetResult() (string, error) {\n\tisMultiselect, err := fileOpenDialog.isMultiselect()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif isMultiselect {\n\t\t// We should panic as this error is caused by the developer using the library\n\t\tpanic(\"use ShowAndGetResults for open multiple files dialog\")\n\t}\n\tif err := fileOpenDialog.Show(); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn fileOpenDialog.GetResult()\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) ShowAndGetResults() ([]string, error) {\n\tisMultiselect, err := fileOpenDialog.isMultiselect()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !isMultiselect {\n\t\t// We should panic as this error is caused by the developer using the library\n\t\tpanic(\"use ShowAndGetResult for open single file dialog\")\n\t}\n\tif err := fileOpenDialog.Show(); err != nil {\n\t\treturn nil, err","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/wailsapp/wails/blob/0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3/v2/internal/go-common-file-dialog/cfd/iFileOpenDialog.go#L35-L71","documentation":"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.","triggerScenarios":"Creating the dialog via the multi-select constructor/path and then calling ShowAndGetResult() instead of ShowAndGetResults().","commonSituations":"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.","solutions":["Call ShowAndGetResults() (plural) on multi-select dialogs","If single-file selection is intended, create the dialog without the multiselect option"],"exampleFix":"// before\ndialog, _ := cfd.NewDialog(cfd.ForceFilePicker) // multiselect set elsewhere\nresult, err := dialog.ShowAndGetResult() // panics\n\n// after\nresults, err := dialog.ShowAndGetResults() // returns []string","handlingStrategy":"type-guard","validationCode":"// know your dialog mode at creation time and store it\nmulti := false // set true only when multiselect was configured\nif multi { paths, err := dialog.ShowAndGetResults() } else { path, err := dialog.ShowAndGetResult() }","typeGuard":"// use the interface the library gives you: MultiFileDialog only exposes the plural APIs\nfunc openFiles(d cfd.MultiFileDialog) ([]string, error) {\n    return d.ShowAndGetResults()\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["file-dialog","windows","api-misuse","panic"],"backgroundTag":null,"analyzedSha":"0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3","analyzedAt":"2026-08-15T14:17:36.034Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}