Standard library / go/build/constraint
go/build/constraint.PlusBuildLines()
Converts an expression to legacy build lines when representable. Expected stdout: '// +build linux,amd64\n'.
Formal Syntax & Structure
go syntaxgo
func PlusBuildLines(x Expr) ([]string, error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | Expr | Input constant or Go value as specified by the function. |
Return Value
([]string, error)
Converts an expression to legacy build lines when representable.
Working Example
Example Snippetgo
package main
import ( "fmt" "go/build/constraint" "strings")
func check(e error) { if e != nil { panic(e) }}
func main() { x, e := constraint.Parse("//go:build linux && amd64") check(e) ls, e := constraint.PlusBuildLines(x) check(e) fmt.Println(strings.Join(ls, ";"))}