Skip to content

Commit

Permalink
refactor: switch to alecthomas/assert/v2
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas committed May 23, 2022
1 parent d21edec commit b0b8e28
Show file tree
Hide file tree
Showing 41 changed files with 90 additions and 113 deletions.
7 changes: 7 additions & 0 deletions .golangci.yml
Expand Up @@ -43,6 +43,13 @@ linters:
- wastedassign
- forcetypeassert
- gomoddirectives
- varnamelen
- exhaustruct
- ireturn
- nonamedreturns
- errname
- nilnil
- maintidx

linters-settings:
govet:
Expand Down
2 changes: 1 addition & 1 deletion _examples/basic/main_test.go
Expand Up @@ -4,7 +4,7 @@ import (
"strings"
"testing"

"github.com/stretchr/testify/require"
require "github.com/alecthomas/assert/v2"
)

func TestExe(t *testing.T) {
Expand Down
17 changes: 8 additions & 9 deletions _examples/ebnf/main.go
Expand Up @@ -7,14 +7,13 @@ import (
"os"
"strings"

"gopkg.in/alecthomas/kingpin.v2"

"github.com/alecthomas/kong"
"github.com/alecthomas/participle/v2"
)

var (
jsonFlag = kingpin.Flag("json", "Display AST as JSON.").Bool()
)
var cli struct {
JSON bool `help:"Display AST as JSON."`
}

type Group struct {
Expression *Expression `"(" @@ ")"`
Expand Down Expand Up @@ -139,7 +138,7 @@ func (e *EBNF) String() string {
var parser = participle.MustBuild(&EBNF{})

func main() {
kingpin.CommandLine.Help = `An EBNF parser compatible with Go"s exp/ebnf. The grammar is
help := `An EBNF parser compatible with Go"s exp/ebnf. The grammar is
in the form:
Production = name "=" [ Expression ] "." .
Expand All @@ -150,13 +149,13 @@ in the form:
Option = "[" Expression "]" .
Repetition = "{" Expression "}" .
`
kingpin.Parse()
ctx := kong.Parse(&cli, kong.Description(help))

ebnf := &EBNF{}
err := parser.Parse("", os.Stdin, ebnf)
kingpin.FatalIfError(err, "")
ctx.FatalIfErrorf(err, "")

if *jsonFlag {
if cli.JSON {
bytes, _ := json.MarshalIndent(ebnf, "", " ")
fmt.Printf("%s\n", bytes)
} else {
Expand Down
2 changes: 1 addition & 1 deletion _examples/ebnf/main_test.go
Expand Up @@ -3,7 +3,7 @@ package main
import (
"testing"

"github.com/stretchr/testify/require"
require "github.com/alecthomas/assert/v2"
)

func TestExe(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion _examples/expr/main_test.go
Expand Up @@ -3,8 +3,8 @@ package main
import (
"testing"

require "github.com/alecthomas/assert/v2"
"github.com/alecthomas/repr"
"github.com/stretchr/testify/require"
)

func TestExe(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion _examples/expr2/main_test.go
Expand Up @@ -3,8 +3,8 @@ package main
import (
"testing"

require "github.com/alecthomas/assert/v2"
"github.com/alecthomas/repr"
"github.com/stretchr/testify/require"
)

func TestExe(t *testing.T) {
Expand Down
16 changes: 9 additions & 7 deletions _examples/go.mod
@@ -1,16 +1,18 @@
module github.com/alecthomas/participle/v2/_examples

go 1.14
go 1.18

require (
github.com/alecthomas/assert/v2 v2.0.3
github.com/alecthomas/go-thrift v0.0.0-20170109061633-7914173639b2
github.com/alecthomas/kong v0.2.11
github.com/alecthomas/kong v0.5.0
github.com/alecthomas/participle/v2 v2.0.0-alpha1
github.com/alecthomas/repr v0.0.0-20200325044227-4184120f674c
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
github.com/stretchr/testify v1.5.1
gopkg.in/alecthomas/kingpin.v2 v2.2.6
github.com/alecthomas/repr v0.1.0
)

require (
github.com/hexops/gotextdiff v1.0.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
)

replace github.com/alecthomas/participle/v2 => ../
41 changes: 16 additions & 25 deletions _examples/go.sum
@@ -1,34 +1,25 @@
github.com/alecthomas/assert/v2 v2.0.3 h1:WKqJODfOiQG0nEJKFKzDIG3E29CN2/4zR9XGJzKIkbg=
github.com/alecthomas/assert/v2 v2.0.3/go.mod h1:b/+1DI2Q6NckYi+3mXyH3wFb8qG37K/DuK80n7WefXA=
github.com/alecthomas/go-thrift v0.0.0-20170109061633-7914173639b2 h1:gKv6LPDhF/G3cNribA+kZtNPiPpKabZGLhcJuEtp3ig=
github.com/alecthomas/go-thrift v0.0.0-20170109061633-7914173639b2/go.mod h1:CxCgO+NdpMdi9SsTlGbc0W+/UNxO3I0AabOEJZ3w61w=
github.com/alecthomas/kong v0.2.1/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
github.com/alecthomas/kong v0.2.8 h1:VSWWkD1TZij2967FcfVwgRwlp3khCA0liZIkUI9hTdU=
github.com/alecthomas/kong v0.2.8/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
github.com/alecthomas/kong v0.2.11 h1:RKeJXXWfg9N47RYfMm0+igkxBCTF4bzbneAxaqid0c4=
github.com/alecthomas/kong v0.2.11/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
github.com/alecthomas/participle/v2 v0.4.1 h1:P2PJWzwrSpuCWXKnzqvw0b0phSfH1kJo4p2HvLynVsI=
github.com/alecthomas/participle/v2 v0.4.1/go.mod h1:T8u4bQOSMwrkTWOSyt8/jSFPEnRtd0FKFMjVfYBlqPs=
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
github.com/alecthomas/repr v0.0.0-20200325044227-4184120f674c h1:MVVbswUlqicyj8P/JljoocA7AyCo62gzD0O7jfvrhtE=
github.com/alecthomas/repr v0.0.0-20200325044227-4184120f674c/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/alecthomas/kong v0.5.0 h1:u8Kdw+eeml93qtMZ04iei0CFYve/WPcA5IFh+9wSskE=
github.com/alecthomas/kong v0.5.0/go.mod h1:uzxf/HUh0tj43x1AyJROl3JT7SgsZ5m+icOv1csRhc0=
github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE=
github.com/alecthomas/repr v0.1.0/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion _examples/graphql/main_test.go
Expand Up @@ -4,7 +4,7 @@ import (
"io/ioutil"
"testing"

"github.com/stretchr/testify/require"
require "github.com/alecthomas/assert/v2"
)

func BenchmarkParser(b *testing.B) {
Expand Down
9 changes: 3 additions & 6 deletions _examples/hcl/main.go
Expand Up @@ -6,8 +6,6 @@ import (
"os"
"strings"

"gopkg.in/alecthomas/kingpin.v2"

"github.com/alecthomas/repr"

"github.com/alecthomas/participle/v2"
Expand Down Expand Up @@ -63,11 +61,10 @@ type Config struct {
var parser = participle.MustBuild(&Config{}, participle.Unquote())

func main() {
kingpin.Parse()

expr := &Config{}
err := parser.Parse("", os.Stdin, expr)
kingpin.FatalIfError(err, "")

if err != nil {
panic(err)
}
repr.Println(expr)
}
2 changes: 1 addition & 1 deletion _examples/hcl/main_test.go
Expand Up @@ -3,8 +3,8 @@ package main
import (
"testing"

require "github.com/alecthomas/assert/v2"
"github.com/alecthomas/repr"
"github.com/stretchr/testify/require"
)

func TestExe(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion _examples/ini/main_test.go
Expand Up @@ -3,8 +3,8 @@ package main
import (
"testing"

require "github.com/alecthomas/assert/v2"
"github.com/alecthomas/repr"
"github.com/stretchr/testify/require"
)

func TestExe(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion _examples/jsonpath/main_test.go
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"testing"

"github.com/stretchr/testify/require"
require "github.com/alecthomas/assert/v2"
)

func TestExe(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion _examples/microc/main_test.go
Expand Up @@ -4,8 +4,8 @@ import (
"strings"
"testing"

require "github.com/alecthomas/assert/v2"
"github.com/alecthomas/repr"
"github.com/stretchr/testify/require"
)

func TestExe(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion _examples/precedenceclimbing/main_test.go
Expand Up @@ -3,7 +3,7 @@ package main
import (
"testing"

"github.com/stretchr/testify/require"
require "github.com/alecthomas/assert/v2"
)

func TestExe(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion _examples/protobuf/main_test.go
Expand Up @@ -3,7 +3,7 @@ package main
import (
"testing"

"github.com/stretchr/testify/require"
require "github.com/alecthomas/assert/v2"
)

func TestExe(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion _examples/simpleexpr/main_test.go
Expand Up @@ -3,8 +3,8 @@ package main
import (
"testing"

require "github.com/alecthomas/assert/v2"
"github.com/alecthomas/repr"
"github.com/stretchr/testify/require"
)

func TestExe(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion _examples/sql/main_test.go
Expand Up @@ -3,8 +3,8 @@ package main
import (
"testing"

require "github.com/alecthomas/assert/v2"
"github.com/alecthomas/repr"
"github.com/stretchr/testify/require"
)

func TestExe(t *testing.T) {
Expand Down
5 changes: 2 additions & 3 deletions _examples/thrift/main.go
Expand Up @@ -12,7 +12,6 @@ import (
"strings"

"github.com/alecthomas/kong"
"gopkg.in/alecthomas/kingpin.v2"

"github.com/alecthomas/repr"

Expand Down Expand Up @@ -228,9 +227,9 @@ func main() {
for _, file := range cli.Files {
thrift := &Thrift{}
r, err := os.Open(file)
kingpin.FatalIfError(err, "")
ctx.FatalIfError(err, "")
err = parser.Parse("", r, thrift)
kingpin.FatalIfError(err, "")
ctx.FatalIfError(err, "")
repr.Println(thrift)
}
}
3 changes: 1 addition & 2 deletions _examples/thrift/main_test.go
Expand Up @@ -5,9 +5,8 @@ import (
"testing"
"time"

require "github.com/alecthomas/assert/v2"
thriftparser "github.com/alecthomas/go-thrift/parser"
"github.com/stretchr/testify/require"

"github.com/alecthomas/participle/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion _examples/toml/main_test.go
Expand Up @@ -3,8 +3,8 @@ package main
import (
"testing"

require "github.com/alecthomas/assert/v2"
"github.com/alecthomas/repr"
"github.com/stretchr/testify/require"
)

func TestExe(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/go
2 changes: 1 addition & 1 deletion bin/gofmt
2 changes: 1 addition & 1 deletion bin/golangci-lint
2 changes: 1 addition & 1 deletion ebnf/ebnf_test.go
Expand Up @@ -3,7 +3,7 @@ package ebnf
import (
"testing"

"github.com/stretchr/testify/require"
require "github.com/alecthomas/assert/v2"
)

func TestEBNF(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion ebnf_test.go
Expand Up @@ -4,7 +4,7 @@ import (
"strings"
"testing"

"github.com/stretchr/testify/require"
require "github.com/alecthomas/assert/v2"
)

func TestEBNF(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions error_test.go
Expand Up @@ -4,8 +4,7 @@ import (
"errors"
"testing"

"github.com/stretchr/testify/require"

require "github.com/alecthomas/assert/v2"
"github.com/alecthomas/participle/v2"
"github.com/alecthomas/participle/v2/lexer"
)
Expand Down
9 changes: 5 additions & 4 deletions go.mod
@@ -1,9 +1,10 @@
module github.com/alecthomas/participle/v2

go 1.16
go 1.18

require (
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/stretchr/testify v1.4.0
github.com/alecthomas/assert/v2 v2.0.3
github.com/alecthomas/repr v0.1.0
)

require github.com/hexops/gotextdiff v1.0.3 // indirect

0 comments on commit b0b8e28

Please sign in to comment.