gopkg.in/hugelgupf/u-root.v2@v2.0.0-20180831055005-3f8fdb0ce09d/cmds/hostname/hostname.go (about)

     1  // Copyright 2012-2017 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Print the system's hostname.
     6  //
     7  // Synopsis:
     8  //     hostname
     9  //
    10  // Author:
    11  //     Beletti <rhiguita@gmail.com>
    12  package main
    13  
    14  import (
    15  	"fmt"
    16  	"log"
    17  	"os"
    18  )
    19  
    20  func main() {
    21  	hostname, err := os.Hostname()
    22  	if err != nil {
    23  		log.Fatalf("could not obtain hostname: %v", err)
    24  	}
    25  
    26  	fmt.Println(hostname)
    27  }