github.com/powerman/golang-tools@v0.1.11-0.20220410185822-5ad214d8d803/internal/lsp/debug/buildinfo_go1.12.go (about)

     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  //go:build !go1.18
     6  // +build !go1.18
     7  
     8  package debug
     9  
    10  import (
    11  	"runtime"
    12  	"runtime/debug"
    13  )
    14  
    15  type BuildInfo struct {
    16  	debug.BuildInfo
    17  	GoVersion string // Version of Go that produced this binary
    18  }
    19  
    20  func readBuildInfo() (*BuildInfo, bool) {
    21  	rinfo, ok := debug.ReadBuildInfo()
    22  	if !ok {
    23  		return nil, false
    24  	}
    25  	return &BuildInfo{
    26  		GoVersion: runtime.Version(),
    27  		BuildInfo: *rinfo,
    28  	}, true
    29  }