显示操作系统类型

  1. package main
  2. import (
  3. "fmt"
  4. "runtime"
  5. )
  6. func main() {
  7. fmt.Println(runtime.GOOS)
  8. }

显示golang版本

  1. package main
  2. import (
  3. "fmt"
  4. "runtime"
  5. )
  6. func main() {
  7. fmt.Printf("%s", runtime.Version())
  8. }