github.com/jd-ly/tools@v0.5.7/internal/testenv/testenv_112.go (about)

     1  // Copyright 2019 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  // +build go1.12
     6  
     7  package testenv
     8  
     9  import "runtime/debug"
    10  
    11  func packageMainIsDevelModule() bool {
    12  	info, ok := debug.ReadBuildInfo()
    13  	if !ok {
    14  		// Most test binaries currently lack build info, but this should become more
    15  		// permissive once https://golang.org/issue/33976 is fixed.
    16  		return true
    17  	}
    18  
    19  	// Note: info.Main.Version describes the version of the module containing
    20  	// package main, not the version of “the main module”.
    21  	// See https://golang.org/issue/33975.
    22  	return info.Main.Version == "(devel)"
    23  }
    24  
    25  func init() {
    26  	packageMainIsDevel = packageMainIsDevelModule
    27  }