1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
package hostname // functions to import and export the protobuf // data to and from config files import ( "os" ) // scutil --get HostName // scutil --get LocalHostName // scutil --get ComputerName // scutil --set HostName my-mac.example.com func osGetHostname() (string, error) { hostname, err := os.Hostname() return hostname, err }