Skip to content

Instantly share code, notes, and snippets.

@techjanitor
Created January 13, 2015 05:21
Show Gist options
  • Save techjanitor/ae833d9afc672f2bb5ca to your computer and use it in GitHub Desktop.
Save techjanitor/ae833d9afc672f2bb5ca to your computer and use it in GitHub Desktop.
a way to check file extensions
package main
import (
"fmt"
"strings"
)
func main() {
ext := ".WEBM"
ext_check := IsValidExt(ext)
if !ext_check {
fmt.Println("no way")
} else {
fmt.Println("cool bro")
}
}
func IsValidExt(ext string) bool {
validExt := map[string]bool{
".jpg": true,
".jpeg": true,
".png": true,
".gif": true,
".webm": true,
}
if validExt[strings.ToLower(ext)] {
return true
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment