Files
llgo/_demo/go/gobuild/demo.go

37 lines
859 B
Go
Raw Normal View History

//go:build go1.23
package main
import (
"fmt"
"go/build"
"runtime"
)
func main() {
fmt.Printf("runtime.Compiler = %q\n", runtime.Compiler)
ctx := build.Default
fmt.Printf("build.Default.Compiler = %q\n", ctx.Compiler)
if ctx.Compiler != "gc" {
panic(fmt.Sprintf("expected build.Default.Compiler to be \"gc\", got %q", ctx.Compiler))
}
if len(ctx.ToolTags) == 0 {
panic("expected build.Default.ToolTags to be non-empty")
}
fmt.Printf("build.Default.ToolTags = %v\n", ctx.ToolTags)
if len(ctx.ReleaseTags) == 0 {
panic("expected build.Default.ReleaseTags to be non-empty")
}
fmt.Printf("build.Default.ReleaseTags count = %d\n", len(ctx.ReleaseTags))
pkg, err := build.Import("fmt", "", build.FindOnly)
if err != nil {
panic(err)
}
fmt.Printf("Package: %s\n", pkg.ImportPath)
fmt.Printf("Success! go/build works with llgo\n")
}