| 1 |
// Copyright 2022 The Go 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 |
// Metadata prints basic system metadata to include in test logs. This is |
| 6 |
// separate from cmd/dist so it does not need to build with the bootstrap |
| 7 |
// toolchain. |
| 8 |
|
| 9 |
// This program is only used by cmd/dist. Add an "ignore" build tag so it |
| 10 |
// is not installed. cmd/dist does "go run main.go" directly. |
| 11 |
|
| 12 |
//go:build ignore |
| 13 |
|
| 14 |
package main |
| 15 |
|
| 16 |
import ( |
| 17 |
"cmd/internal/osinfo" |
| 18 |
"fmt" |
| 19 |
"internal/sysinfo" |
| 20 |
"runtime" |
| 21 |
) |
| 22 |
|
| 23 |
func main() { |
| 24 |
fmt.Printf("# GOARCH: %s\n", runtime.GOARCH) |
| 25 |
fmt.Printf("# CPU: %s\n", sysinfo.CPUName()) |
| 26 |
|
| 27 |
fmt.Printf("# GOOS: %s\n", runtime.GOOS) |
| 28 |
ver, err := osinfo.Version() |
| 29 |
if err != nil { |
| 30 |
ver = fmt.Sprintf("UNKNOWN: error determining OS version: %v", err) |
| 31 |
} |
| 32 |
fmt.Printf("# OS Version: %s\n", ver) |
| 33 |
} |