Standard library / go/build
go/build.Package.IsCommand()
Reports whether the package is named main. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (p *Package) IsCommand() boolReturn Value
bool
Reports whether the package is named main.
Working Example
Example Snippetgo
package main
import ( "fmt" "go/build")
func main() { p := build.Package{Name: "main"}; fmt.Println(p.IsCommand()) }