This code will panic in the unlikely event that path is less than 3 characters long. It'd be safer to use strings.HasSuffix(). You could use path/filepath.Ext(), but that'd be slightly less efficient (probably not a big deal here) and more code (less code is nearly always better).