Created
October 22, 2021 07:42
-
-
Save kyberorg/1ca2530d6cc7e8267a845359edf6c9dc to your computer and use it in GitHub Desktop.
Container Walker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.17.2 as walker-build | |
WORKDIR /go/src/app | |
COPY cmd/walker.go cmd/walker.go | |
RUN GO111MODULE=off CGO_ENABLED=0 go install ./... | |
FROM your-image-here:tag as runner | |
COPY --from=walker-build /go/bin/cmd /app/walker | |
ENTRYPOINT ["/app/walker"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io/fs" | |
"log" | |
"path/filepath" | |
) | |
func main() { | |
err := filepath.Walk("/usr", | |
func(path string, info fs.FileInfo, err error) error { | |
if err != nil { | |
log.Println(err) | |
} | |
fmt.Println(path) | |
return nil | |
}) | |
if err != nil { | |
log.Panicln(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment