Skip to content

Commit 4e5483f

Browse files
committed
added guard clause instead of extra loop
1 parent c3f0077 commit 4e5483f

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

cmd/gh-classroom/pull/student-repos/student-repos.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,15 @@ func NewCmdStudentReposPull(f *cmdutil.Factory) *cobra.Command {
7171
log.Fatal(err)
7272
}
7373

74-
all_entries, err := os.ReadDir(fullPath)
74+
entries, err := os.ReadDir(fullPath)
7575
if err != nil {
7676
log.Fatal(err)
7777
}
7878

79-
//filter entries to only directories
80-
var entries []os.DirEntry
81-
for _, r := range all_entries {
82-
if r.IsDir() {
83-
entries = append(entries, r)
84-
}
85-
}
86-
8779
for _, r := range entries {
80+
if !r.IsDir() {
81+
continue
82+
}
8883
clonePath := filepath.Join(fullPath, r.Name())
8984
fmt.Printf("Pulling repo: %v\n", clonePath)
9085
err = os.Chdir(clonePath)

0 commit comments

Comments
 (0)