Skip to main content

detect_language

Function detect_language 

Source
pub fn detect_language(dir: &Path) -> Language
👎Deprecated:

请使用 detect_languages,它独立检测所有语言而非按优先级返回首个

Expand description

根据目录下的标志文件推测编程语言(按优先级返回首个匹配)。

优先级:Cargo.toml > pyproject.toml/requirements.txt > go.mod > pubspec.yaml > package.json

已废弃:请使用 detect_languages 替代,它会独立检测所有语言, 不丢失 monorepo 多语言信息。

use std::path::Path;
use quanttide_devops::source::config_file::detect_language;

let lang = detect_language(Path::new("/tmp/nonexistent"));
assert!(matches!(lang, quanttide_devops::contract::Language::Unknown(_)));