INNER CODE UNIT · Go

moduleRoot

Leadaxe/LxBox · app/contract/tools/gendocs/main.go:109

func moduleRoot() (string, error) {
	wd, err := os.Getwd()
	if err != nil {
		return "", err
	}
	dir := wd
	for {
		if _, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil {
			return dir, nil
		}
		parent := filepath.Dir(dir)
		if parent == dir {
			return "", fmt.Errorf("не найден корень модуля (go.mod) вверх от %s", wd)
		}
		dir = parent
	}
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…