{"record":{"id":"26a73c0fcb23c32a","repo":"wailsapp/wails","slug":"use-getresults-for-open-multiple-files-dialog","errorCode":null,"errorMessage":"use GetResults for open multiple files dialog","messagePattern":"use GetResults for open multiple files dialog","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v2/internal/go-common-file-dialog/cfd/iFileOpenDialog.go","lineNumber":87,"sourceCode":"\t}\n\tif err := fileOpenDialog.Show(); err != nil {\n\t\treturn nil, err\n\t}\n\treturn fileOpenDialog.GetResults()\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) SetTitle(title string) error {\n\treturn fileOpenDialog.vtbl.setTitle(unsafe.Pointer(fileOpenDialog), title)\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) GetResult() (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 GetResults for open multiple files dialog\")\n\t}\n\treturn fileOpenDialog.vtbl.getResultString(unsafe.Pointer(fileOpenDialog))\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) Release() error {\n\treturn fileOpenDialog.vtbl.release(unsafe.Pointer(fileOpenDialog))\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) SetDefaultFolder(defaultFolderPath string) error {\n\treturn fileOpenDialog.vtbl.setDefaultFolder(unsafe.Pointer(fileOpenDialog), defaultFolderPath)\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) SetFolder(defaultFolderPath string) error {\n\treturn fileOpenDialog.vtbl.setFolder(unsafe.Pointer(fileOpenDialog), defaultFolderPath)\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) SetFileFilters(filter []FileFilter) error {\n\treturn fileOpenDialog.vtbl.setFileTypes(unsafe.Pointer(fileOpenDialog), filter)","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/wailsapp/wails/blob/0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3/v2/internal/go-common-file-dialog/cfd/iFileOpenDialog.go#L69-L105","documentation":"GetResult() (singular) panics when called on a multi-select dialog because the single-result COM call cannot faithfully represent the user's multiple selections. Like its siblings, this is an intentional panic for developer API misuse.","triggerScenarios":"Calling GetResult() directly on a dialog created with the multiselect flag, typically after a manual Show() call instead of using ShowAndGetResult.","commonSituations":"Splitting show/result into separate steps (e.g. to inspect the dialog lifetime) and using the wrong result accessor for a multi-select dialog.","solutions":["Use GetResults() (plural) on multi-select dialogs","Prefer the paired helpers ShowAndGetResults() which enforce the correct combination"],"exampleFix":"// before\nif err := dialog.Show(); err == nil {\n    path, err := dialog.GetResult() // multiselect: panics\n}\n\n// after\nif err := dialog.Show(); err == nil {\n    paths, err := dialog.GetResults()\n}","handlingStrategy":"type-guard","validationCode":"// after a manual Show(), match the accessor to the dialog mode\nif multi {\n    paths, err := dialog.GetResults()\n} else {\n    path, err := dialog.GetResult()\n}","typeGuard":"var _ cfd.MultiFileDialog = dialog // compile-time proof plural accessors are legal\npaths, err := dialog.GetResults()","tryCatchPattern":null,"preventionTips":["Prefer ShowAndGetResults() over manual Show()+GetResults() sequences","Keep the multiselect flag decision and the accessor calls adjacent in code"],"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"}