Skip to content

Instantly share code, notes, and snippets.

@kyberorg
Created October 22, 2021 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyberorg/1ca2530d6cc7e8267a845359edf6c9dc to your computer and use it in GitHub Desktop.
Save kyberorg/1ca2530d6cc7e8267a845359edf6c9dc to your computer and use it in GitHub Desktop.
Container Walker
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"]
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