blob: ae80a5398a97358fa59842da9c14b3b055bbb285 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
[](https://goreportcard.com/report/github.com/go-toolsmith/strparse)
[](https://godoc.org/github.com/go-toolsmith/strparse)
[](https://travis-ci.org/go-toolsmith/strparse)
# strparse
Package strparse provides convenience wrappers around `go/parser` for simple
expression, statement and declaretion parsing from string.
## Installation
```bash
go get github.com/go-toolsmith/strparse
```
## Example
```go
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
}
```
|