How do you golang know the download of the processor, the name of the computer and the user's name on the computer?



  • How do you golang know the download of the processor, the name of the computer and the user's name on the computer?



  • Stackoverflow isn't supposed to mix a lot of questions into one.

    1. Current user name

    Package https://godoc.org/os/user ♪ Example:

    package main
    

    import (
    "os/user"
    "log"
    "fmt"
    )

    func main() {
    // текущий пользователь
    cur, err := user.Current()
    if err != nil {
    log.Fatal(err)
    }
    fmt.Println("Current user:", cur)
    }

    There's also a user choice by name and identifier. Here. play.golang.org It doesn't work.

    2. Computer name.

    Function https://godoc.org/os#Hostname ♪ https://play.golang.org/p/2JuesNtAXz

    3. Processor load.

    Use the outside library.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2