Created
October 27, 2014 01:33
-
-
Save kristianfreeman/172f0ee562f6e866e84b to your computer and use it in GitHub Desktop.
My very first go function, d'aww
This file contains hidden or 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
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