中的 loopThroughDirs 函数> filepath.Walk() loopThroughDirs
WalkFunc
func main(){
service ,ERR:= storage.New(客户端)
...
filepath.Walk(*目录名,getWalkFunc(服务))
}
FUNC getWalkFunc(服务storage.Service)filepath.WalkFunc {
return func(path string,fileInfo os.FileInfo,err error)error {
// ...做一些服务...
return nil
}
}
I have the following code:
func loopThroughDirs(path string, fileInfo os.FileInfo, err error) error {
...do something with service...
return nil
}
func main() {
service, err := storage.New(client)
...
filepath.Walk(*dirName, loopThroughDirs)
}
serviceloopThroughDirs()
func main() {
service, err := storage.New(client)
...
filepath.Walk(*dirName, getWalkFunc(service))
}
func getWalkFunc(service storage.Service) filepath.WalkFunc {
return func(path string, fileInfo os.FileInfo, err error) error {
// ...do something with service...
return nil
}
}