xxxxxxxxxx
package main
import (
"fmt"
"log"
"path/filepath"
)
func main() {
files, err := filepath.Glob("testFolder/*.go")
if err != nil {
log.Fatal(err)
}
for _, file := range files {
fmt.Println(file)
}
}
xxxxxxxxxx
package main
import (
"fmt"
"log"
"os"
"path/filepath"
)
func main() {
err := filepath.Walk("testFolder",
func(path string, _ os.FileInfo, err error) error {
if err != nil {
return err
}
fmt.Println(path)
return nil
})
if err != nil {
log.Fatal(err)
}
}