Skip to content

Instantly share code, notes, and snippets.

@kristianfreeman
Created October 27, 2014 01:33
Show Gist options
  • Save kristianfreeman/172f0ee562f6e866e84b to your computer and use it in GitHub Desktop.
Save kristianfreeman/172f0ee562f6e866e84b to your computer and use it in GitHub Desktop.
My very first go function, d'aww
func files(dir string) ([]string, error) {
files, err := ioutil.ReadDir(dir)
if err != nil {
return nil, err
}
filenames := make([]string, 0)
for _, f := range files {
if string(f.Name()[0]) != "." {
filenames = append(filenames, f.Name())
}
}
return filenames, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment