{"record":{"id":"19562fa343c77ee4","repo":"wailsapp/wails","slug":"use-getresult-for-open-single-file-dialog","errorCode":null,"errorMessage":"use GetResult for open single file dialog","messagePattern":"use GetResult for open single file dialog","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v2/internal/go-common-file-dialog/cfd/iFileOpenDialog.go","lineNumber":121,"sourceCode":"\nfunc (fileOpenDialog *iFileOpenDialog) SetFileFilters(filter []FileFilter) error {\n\treturn fileOpenDialog.vtbl.setFileTypes(unsafe.Pointer(fileOpenDialog), filter)\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) SetRole(role string) error {\n\treturn fileOpenDialog.vtbl.setClientGuid(unsafe.Pointer(fileOpenDialog), StringToUUID(role))\n}\n\n// This should only be callable when the user asks for a multi select because\n// otherwise they will be given the Dialog interface which does not expose this function.\nfunc (fileOpenDialog *iFileOpenDialog) GetResults() ([]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 GetResult for open single file dialog\")\n\t}\n\treturn fileOpenDialog.vtbl.getResultsStrings(unsafe.Pointer(fileOpenDialog))\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) SetDefaultExtension(defaultExtension string) error {\n\treturn fileOpenDialog.vtbl.setDefaultExtension(unsafe.Pointer(fileOpenDialog), defaultExtension)\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) SetFileName(initialFileName string) error {\n\treturn fileOpenDialog.vtbl.setFileName(unsafe.Pointer(fileOpenDialog), initialFileName)\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) SetSelectedFileFilterIndex(index uint) error {\n\treturn fileOpenDialog.vtbl.setSelectedFileFilterIndex(unsafe.Pointer(fileOpenDialog), index)\n}\n\nfunc (fileOpenDialog *iFileOpenDialog) setPickFolders(pickFolders bool) error {\n\tconst FosPickfolders = 0x20","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/wailsapp/wails/blob/0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3/v2/internal/go-common-file-dialog/cfd/iFileOpenDialog.go#L103-L139","documentation":"GetResults() (plural) panics when called on a single-select dialog. The library comment notes this method should only be reachable for multi-select dialogs since the single-select Dialog interface does not expose it; hitting the panic means the wrong interface/method pairing was used.","triggerScenarios":"Calling GetResults() on a dialog created without the multiselect option, usually via a type-asserted or directly-constructed iFileOpenDialog.","commonSituations":"Writing generic helper code that always calls GetResults() regardless of dialog kind, or holding the concrete type instead of the Dialog/MultiFileDialog interface.","solutions":["Use GetResult() (singular) on single-select dialogs","Type-hint variables as cfd.Dialog or cfd.MultiFileDialog so only the correct methods are visible"],"exampleFix":"// before\nvar d cfd.MultiFileDialog = singleSelectDialog // or direct concrete use\npaths, _ := d.GetResults() // panics\n\n// after\nvar d cfd.Dialog = singleSelectDialog\npath, _ := d.ShowAndGetResult()","handlingStrategy":"type-guard","validationCode":"// single-select: singular accessor only\npath, err := dialog.GetResult()","typeGuard":"func resultOf(d cfd.Dialog) (string, error) {\n    // Dialog interface hides GetResults; misuse becomes a compile error\n    return d.GetResult()\n}","tryCatchPattern":null,"preventionTips":["Never type-assert a single dialog to MultiFileDialog","Return the narrow interface (Dialog) from your dialog factory so plural APIs are invisible"],"tags":["file-dialog","windows","api-misuse","panic"],"backgroundTag":null,"analyzedSha":"0e754b1b40ba9044c2a1460e23b7c3de20fc5cf3","analyzedAt":"2026-08-15T14:17:36.034Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}