go-clone/readWorkFile.go

50 lines
719 B
Go
Raw Permalink Normal View History

2024-03-07 00:50:58 -06:00
package main
import (
"bufio"
"os"
2024-03-09 09:23:04 -06:00
"path/filepath"
2024-03-07 00:50:58 -06:00
"strings"
2024-03-07 16:45:49 -06:00
"go.wit.com/lib/gui/shell"
2024-03-07 00:50:58 -06:00
"go.wit.com/log"
)
2024-03-07 16:45:49 -06:00
func addDir(d string) {
if shell.IsDir(d) {
rv.NewRepo(d)
}
}
2024-03-09 09:23:04 -06:00
func readControlFile(path string) error {
fullname := filepath.Join(path, "go.work")
file, err := os.Open(fullname)
2024-03-07 00:50:58 -06:00
if err != nil {
return err
}
defer file.Close()
// pairs := make(map[string]string)
// var key string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := scanner.Text()
line = strings.TrimSpace(line)
partsNew := strings.SplitN(line, ":", 2)
if len(partsNew) > 1 {
continue
}
log.Info(line)
2024-03-07 16:45:49 -06:00
addDir(line)
2024-03-07 00:50:58 -06:00
}
if err := scanner.Err(); err != nil {
return err
}
return nil
}