The other day we were chatting with a colleague of mine about retrieving the OS name of the distribution. I don't recall exactly the details, but it was something about always getting the actual distribution name and not the upstream one, and he could not sort that out (I have my suspicions that he didn't try very hard).
Fast forward 2 weeks, I'm sipping coffee and installing updates on my laptop and suddenly this appears on the screen:
Oh, that's interesting 🤔, let's google "rust distribution id_like"? LMGTFY
BOOM! first result: https://docs.rs/os-release/0.1.0/os_release/struct.OsRelease.html
Looks good, let's give it a try:
> cargo new guess_os
> cd guess_os
> cargo add os-release
> vim src/main.go
very well now let's add the code
extern crate os_release;
use os_release::OsRelease;
use std::io;
pub fn main() -> io::Result<()> {
let release = OsRelease::new()?;
println!("You say '{}', I say '{}'", release.name, release.id_like);
Ok(())
}
And now the moment of truth 🥁
🏆
Top comments (0)