workgroups/vendor/github.com/go-toolsmith/strparse
Marvin Preuss 1d4ae27878
All checks were successful
continuous-integration/drone/push Build is passing
ci: drone yaml with reusable anchors
2021-09-24 17:34:17 +02:00
..
.travis.yml ci: drone yaml with reusable anchors 2021-09-24 17:34:17 +02:00
LICENSE ci: drone yaml with reusable anchors 2021-09-24 17:34:17 +02:00
README.md ci: drone yaml with reusable anchors 2021-09-24 17:34:17 +02:00
strparse.go ci: drone yaml with reusable anchors 2021-09-24 17:34:17 +02: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
}