MCPcopy Index your code
hub / github.com/wailsapp/wails / loadCustomCode

Function loadCustomCode

v2/internal/typescriptify/typescriptify.go:424–458  ·  view source on GitHub ↗
(fileName string)

Source from the content-addressed store, hash-verified

422}
423
424func loadCustomCode(fileName string) (map[string]string, error) {
425 result := make(map[string]string)
426 f, err := os.Open(fileName)
427 if err != nil {
428 if os.IsNotExist(err) {
429 return result, nil
430 }
431 return result, err
432 }
433 defer f.Close()
434
435 bytes, err := io.ReadAll(f)
436 if err != nil {
437 return result, err
438 }
439
440 var currentName string
441 var currentValue string
442 lines := strings.Split(string(bytes), "\n")
443 for _, line := range lines {
444 trimmedLine := strings.TrimSpace(line)
445 if strings.HasPrefix(trimmedLine, "//[") && strings.HasSuffix(trimmedLine, ":]") {
446 currentName = strings.Replace(strings.Replace(trimmedLine, "//[", "", -1), ":]", "", -1)
447 currentValue = ""
448 } else if trimmedLine == "//[end]" {
449 result[currentName] = strings.TrimRight(currentValue, " \t\r\n")
450 currentName = ""
451 currentValue = ""
452 } else if len(currentName) > 0 {
453 currentValue += line + "\n"
454 }
455 }
456
457 return result, nil
458}
459
460func (t TypeScriptify) backup(fileName string) error {
461 fileIn, err := os.Open(fileName)

Callers 1

ConvertToFileMethod · 0.85

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…