distro/distro.go
func Detect() (Distro, error) {
	var id string
	var err error

	if _, err = os.Stat("/etc/os-release"); !os.IsNotExist(err) {
		cfg, err := shconf.ParseFile("/etc/os-release")
		if err != nil {
			return 0, err
		}

		if id, err = cfg.Get("ID"); err != nil {
			return 0, err
		}
		if v, found := idToDistro[id]; found {
			return v, nil
		}

	} else if _, err = os.Stat("/etc/centos-release"); !os.IsNotExist(err) {
		return CentOS, nil
	} else if _, err = os.Stat("/etc/pclinuxos-release"); !os.IsNotExist(err) {
		return PCLinuxOS, nil
	}

	panic("Linux distribution unsopported")
}
func Detect() (Distro, error) {
	var id string
	var err error

	if _, err = os.Stat("/etc/os-release"); !os.IsNotExist(err) {
		cfg, err := shconf.ParseFile("/etc/os-release")
		if err != nil {
			return 0, err
		}

		if id, err = cfg.Get("ID"); err != nil {
			return 0, err
		}
		if v, found := idToDistro[id]; found {
			return v, nil
		}

	} else if _, err = os.Stat("/etc/centos-release"); !os.IsNotExist(err) {
		return CentOS, nil
	} else if _, err = os.Stat("/etc/pclinuxos-release"); !os.IsNotExist(err) {
		return PCLinuxOS, nil
	}

	panic("Linux distribution unsopported")
}
func Detect ( ) ( Distro , error ) { var id string var err error if _ , err = os . Stat ( " " ) ; ! os . IsNotExist ( err ) { cfg , err := shconf . ParseFile ( " " ) if err != nil { return 0 , err } if id , err = cfg . Get ( " " ) ; err != nil { return 0 , err } if v , found := idToDistro [ id ] ; found { return v , nil } } else if _ , err = os . Stat ( " " ) ; ! os . IsNotExist ( err ) { return CentOS , nil } else if _ , err = os . Stat ( " " ) ; ! os . IsNotExist ( err ) { return PCLinuxOS , nil } panic ( " " ) }
// Detect returns the Linux distribution.
Detect returns the Linux distribution .