wg-quicker/vendor/github.com/go-toolsmith/strparse
2022-01-07 20:20:48 +01:00
..
.travis.yml build: managing tools in go modules 2022-01-07 20:20:48 +01:00
go.mod build: managing tools in go modules 2022-01-07 20:20:48 +01:00
LICENSE build: managing tools in go modules 2022-01-07 20:20:48 +01:00
README.md build: managing tools in go modules 2022-01-07 20:20:48 +01:00
strparse.go build: managing tools in go modules 2022-01-07 20:20:48 +01:00

Go Report Card GoDoc Build Status

strparse

Package strparse provides convenience wrappers around go/parser for simple expression, statement and declaretion parsing from string.

Installation

go get github.com/go-toolsmith/strparse

Example

package main

import (
	"go-toolsmith/astequal"
	"go-toolsmith/strparse"
)

func main() {
	// Comparing AST strings for equallity (note different spacing):
	x := strparse.Expr(`1 + f(v[0].X)`)
	y := strparse.Expr(` 1+f( v[0].X ) `)
	fmt.Println(astequal.Expr(x, y)) // => true
}