5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 19:50:15 +08:00

Add compatibility for Go1.17 (#1605)

This commit is contained in:
Lea Anthony 2022-07-20 07:10:05 +10:00 committed by GitHub
parent 41126759cf
commit 461d0c4448
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -129,7 +129,13 @@ func goTypeToJSDocType(input string, importNamespaces *slicer.StringSlicer) stri
return "string"
case strings.HasPrefix(input, "map"):
temp := strings.TrimPrefix(input, "map[")
keyType, valueType, _ := strings.Cut(temp, "]")
// Split the string into the key and value types
tempSplit := strings.SplitN(temp, "]", 2)
if len(tempSplit) < 2 {
panic("Invalid map type provided: " + input)
}
keyType := tempSplit[0]
valueType := tempSplit[1]
return fmt.Sprintf("{[key: %s]: %s}", goTypeToJSDocType(keyType, importNamespaces), goTypeToJSDocType(valueType, importNamespaces))
case strings.HasPrefix(input, "[]"):
arrayType := goTypeToJSDocType(input[2:], importNamespaces)