move functionality unrelated to getFiles into main func

This commit is contained in:
yangkb09 2023-06-06 17:34:04 -04:00
parent 5a35955659
commit a36e72e546

View File

@ -28,19 +28,33 @@ best way to test things is usually to use test functions, and not the main func
no diff b/n test func and main func no diff b/n test func and main func
*/ */
// input: module name, output: list of files that import it
// how??
func getFiles(moduleName string) ([]string, error) { func getFiles(moduleName string) ([]string, error) {
fmt.Println("I AM GET FILES") fmt.Println("I AM GET FILES")
// get list of modules
// for each module, return a list of files that import it
// DO NOW: determine how to get list of files that import a module based on module name
return []string{}, nil
}
func main() {
// parse go.mod to get list of modules
m, err := parseGoMod(os.DirFS("."), "go.mod") m, err := parseGoMod(os.DirFS("."), "go.mod")
if err != nil { if err != nil {
return nil, err return nil, err
} }
// for each module, return a list of files that import it // for each direct module, get list of files that import it
for _, mod := range m { for _, mod := range m {
if mod.Indirect == false { if mod.Indirect == false {
files, err := getFiles(mod)
fmt.Println(mod) fmt.Println(mod)
if err != nil {
return nil, err
}
} }
} }
return []string{}, nil
} }