Source File
mod.go
Belonging Package
runtime/debug
package debug
import (
)
func () string
func () ( *BuildInfo, bool) {
return readBuildInfo(modinfo())
}
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
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
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |