FileTypeForPath returns the FileType for the given path. Returns error if the path cannot be classified as a FileType, that is if it is not a .proto file, license file, or documentation file. Note that license and documentation files must be at the root, and cannot be in subdirectories. That is, s
(path string)
| 81 | // Note that license and documentation files must be at the root, and cannot be in subdirectories. That is, |
| 82 | // subdir/LICENSE will not be classified as a FileTypeLicense, but LICENSE will be. |
| 83 | func FileTypeForPath(path string) (FileType, error) { |
| 84 | if normalpath.Ext(path) == ".proto" { |
| 85 | return FileTypeProto, nil |
| 86 | } |
| 87 | if path == licenseFilePath { |
| 88 | return FileTypeLicense, nil |
| 89 | } |
| 90 | if _, ok := docFilePathMap[path]; ok { |
| 91 | return FileTypeDoc, nil |
| 92 | } |
| 93 | return 0, fmt.Errorf("could not classify FileType for path %q", path) |
| 94 | } |
| 95 | |
| 96 | // IsValidModuleFilePath returns true if the given file path is a valid Module file path. |
| 97 | // |
no test coverage detected
searching dependent graphs…