package file import ( "errors" "path/filepath" ) var ErrNames = errors.New("please use naming scheme of keyname.pub and keyname.sec") func Names(pubFile, encFile string) error { pubFile = filepath.Base(pubFile) encFile = filepath.Base(encFile) pubExt := filepath.Ext(pubFile) encExt := filepath.Ext(encFile) if pubExt != ".pub" || encExt != ".sec" || pubFile[:len(pubExt)-1] != encFile[:len(encExt)-1] { return ErrNames } return nil } func PubName(encFile string) string { ext := filepath.Ext(encFile) return filepath.Base(encFile[:len(ext)-1] + ".pub") }