Copyright 2018 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.

package debug

import (
	
)
exported from runtime
func () string
ReadBuildInfo returns the build information embedded in the running binary. The information is available only in binaries built with module support.
func () ( *BuildInfo,  bool) {
	return readBuildInfo(modinfo())
}
BuildInfo represents the build information read from the running binary.
type BuildInfo struct {
	Path string    // The main package path
	Main Module    // The module containing the main package
	Deps []*Module // Module dependencies
}
Module represents a module.
type Module struct {
	Path    string  // module path
	Version string  // module version
	Sum     string  // checksum
	Replace *Module // replaced by this module
}

func ( string) (*BuildInfo, bool) {
	if len() < 32 {
		return nil, false
	}
	 = [16 : len()-16]

	const (
		 = "path\t"
		  = "mod\t"
		  = "dep\t"
		  = "=>\t"
	)

	 := func( []string) (Module, bool) {
		if len() != 2 && len() != 3 {
			return Module{}, false
		}
		 := ""
		if len() == 3 {
			 = [2]
		}
		return Module{
			Path:    [0],
			Version: [1],
			Sum:     ,
		}, true
	}

	var (
		 = &BuildInfo{}
		 *Module
		 string
		   bool
Reverse of cmd/go/internal/modload.PackageBuildInfo
	for len() > 0 {
		 := strings.IndexByte(, '\n')
		if  < 0 {
			break
		}
		,  = [:], [+1:]
		switch {
		case strings.HasPrefix(, ):
			 := [len():]
			.Path = 
		case strings.HasPrefix(, ):
			 := strings.Split([len():], "\t")
			 = &.Main
			*,  = ()
			if ! {
				return nil, false
			}
		case strings.HasPrefix(, ):
			 := strings.Split([len():], "\t")
			 = new(Module)
			.Deps = append(.Deps, )
			*,  = ()
			if ! {
				return nil, false
			}
		case strings.HasPrefix(, ):
			 := strings.Split([len():], "\t")
			if len() != 3 {
				return nil, false
			}
			if  == nil {
				return nil, false
			}
			.Replace = &Module{
				Path:    [0],
				Version: [1],
				Sum:     [2],
			}
			 = nil
		}
	}
	return , true