aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/dist/metadata.go
blob: 76f108ea062f25ce80c632ce11ad264960e722ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Helper to print system metadata (CPU model, etc). This uses packages that
// may not be available in the bootstrap toolchain. It only needs to be built
// on the dist build using the final toolchain.

//go:build go1.18
// +build go1.18

package main

import (
	"cmd/internal/osinfo"
	"fmt"
	"internal/sysinfo"
	"runtime"
)

func logMetadata() error {
	fmt.Printf("# GOARCH: %s\n", runtime.GOARCH)
	fmt.Printf("# CPU: %s\n", sysinfo.CPU.Name())

	fmt.Printf("# GOOS: %s\n", runtime.GOOS)
	ver, err := osinfo.Version()
	if err != nil {
		return fmt.Errorf("error determining OS version: %v", err)
	}
	fmt.Printf("# OS Version: %s\n", ver)

	return nil
}