Standard library / go/build/constraint

go/build/constraint.Parse()

Parses a single modern or legacy build constraint line. Expected stdout: 'linux && amd64\n'.

Formal Syntax & Structure

go syntaxgo
func Parse(line string) (Expr, error)

Parameters & Attributes

NameTypeDescription
linestringInput to the operation as described above.

Return Value

(Expr, error)

Parses a single modern or legacy build constraint line.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/build/constraint")
func check(e error) {  if e != nil {    panic(e)  }}
func main() { x, e := constraint.Parse("//go:build linux && amd64"); check(e); fmt.Println(x.String()) }
Go Reference