ReadDir not return filename?

@alexandros that doesn’t look entirely correct. Let me try to do a shorter version:

readDir returns a slice of https://golang.org/pkg/os/#FileInfo

So you need to do something ala:

{{ $dir := "cool-images" }}
{{ $images := readDir $dir | shuffle }}
{{ $first := index $images 0 }}
{{ $path := path.Join $dir $first.Name }}

I created this issue to make this function a little easier to use:

But @alexandros is correct about the resources, and I suspect that putting the images in /assets and using resources.Match etc. would make it easier.

1 Like