1
0
mirror of https://github.com/google/gops.git synced 2024-11-19 20:31:58 +02:00
gops/goprocess/goprocess_lt1.18.go
Tobias Klauser 53ee352cc8 goprocess: use debug/buildinfo on Go 1.18 and newer
Use package debug/buildinfo [1] introduced in Go 1.18 [2] when possible.
This should avoid previous issues with rsc.io/goversion where Go
processes were no longer listed.

[1] https://pkg.go.dev/debug/buildinfo
[2] https://go.dev/doc/go1.18#debug/buildinfo

For #102
For #159
For #160
2022-05-04 22:48:20 +02:00

19 lines
425 B
Go

// Copyright 2022 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.
//go:build !go1.18
// +build !go1.18
package goprocess
import goversion "rsc.io/goversion/version"
func goVersion(path string) (string, error) {
versionInfo, err := goversion.ReadExe(path)
if err != nil {
return "", err
}
return versionInfo.Release, nil
}