package main
import (
"fmt"
"go/parser"
)
func main() {
ast0, err := parser.ParseExpr("var a = 9")
fmt.Printf("err = %v\n", err)
fmt.Printf("ast0 = %#v\n", ast0)
}
$go run simple.go
err = 1:1: expected operand, found 'var'
ast0 = <nil>
$
Pedantically, perhaps this is a statement rather than an expression. That begs the question, is there anyway to parse single statements (using go/parse)?