Created
January 13, 2015 05:21
-
-
Save techjanitor/ae833d9afc672f2bb5ca to your computer and use it in GitHub Desktop.
a way to check file extensions
This file contains 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
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