You can use the os
package in Go to get the operating system's release information using the uname
command. Here's an example:
main.go254 chars19 lines
The exec
package provides the Command
function which allows you to specify a command to be executed along with any arguments. In this case, we're executing the uname -r
command which prints the kernel release information. We then use the Output
function of the Cmd
structure to run the command and capture its output. Finally, we print the resulting release string to the console.
gistlibby LogSnag