50 lines
719 B
Go
50 lines
719 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"go.wit.com/lib/gui/shell"
|
|
"go.wit.com/log"
|
|
)
|
|
|
|
func addDir(d string) {
|
|
if shell.IsDir(d) {
|
|
rv.NewRepo(d)
|
|
}
|
|
}
|
|
|
|
func readControlFile(path string) error {
|
|
fullname := filepath.Join(path, "go.work")
|
|
file, err := os.Open(fullname)
|
|
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)
|
|
addDir(line)
|
|
}
|
|
|
|
if err := scanner.Err(); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|