{"record":{"id":"4ea5c62ec07f369b","repo":"wailsapp/wails","slug":"use-showandgetresults-for-open-multiple-files-dial-4ea5c6","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":"v3/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/v3/internal/go-common-file-dialog/cfd/iFileOpenDialog.go#L35-L71","documentation":"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.","triggerScenarios":"Building a multi-select FileOpen dialog in a Wails v3 app and calling ShowAndGetResult() (singular).","commonSituations":"Porting v2 dialog code into v3, or writing a generic 'pick file(s)' helper that always uses the singular call.","solutions":["Use ShowAndGetResults() (plural) for multi-select dialogs","Create the dialog without multiselect if only one file is wanted"],"exampleFix":"// before\npath, err := dialog.ShowAndGetResult() // multiselect dialog: panics\n\n// after\npaths, err := dialog.ShowAndGetResults()","handlingStrategy":"type-guard","validationCode":"// track dialog mode where you create it and branch once\nif multiSelect {\n    paths, err := dialog.ShowAndGetResults()\n} else {\n    path, err := dialog.ShowAndGetResult()\n}","typeGuard":"func openFilesV3(d cfd.MultiFileDialog) ([]string, error) {\n    return d.ShowAndGetResults()\n}","tryCatchPattern":null,"preventionTips":["Type dialog variables as cfd.Dialog or cfd.MultiFileDialog in v3 too","Centralize dialog calls in OpenFile/OpenFiles wrappers per mode"],"tags":["file-dialog","windows","api-misuse","panic","v3"],"backgroundTag":null,"analyzedSha":"0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3","analyzedAt":"2026-08-15T14:17:36.034Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}