diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 3a48e4f..8d398ca 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -42,7 +42,7 @@ jobs: name: Test strategy: matrix: - go-version: [ 1.16.x, 1.17.x, 1.18.x ] + go-version: [ 1.18.x, 1.19.x ] platform: [ ubuntu-latest, macos-latest, windows-latest ] runs-on: ${{ matrix.platform }} steps: diff --git a/README.md b/README.md index 1e63817..dd19c2e 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ It is the successor of the [Macaron](https://github.com/go-macaron/macaron), and ## Installation -The minimum requirement of Go is **1.16**. +The minimum requirement of Go is **1.18**. go get github.com/flamego/flamego diff --git a/go.mod b/go.mod index addd18e..fb18883 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,19 @@ module github.com/flamego/flamego -go 1.16 +go 1.18 require ( - github.com/alecthomas/participle/v2 v2.0.0-alpha10 + github.com/alecthomas/participle/v2 v2.0.0-beta.5 github.com/fatih/color v1.13.0 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.8.0 ) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/mattn/go-colorable v0.1.9 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum index 31f8720..5dd8b67 100644 --- a/go.sum +++ b/go.sum @@ -1,16 +1,13 @@ 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/participle/v2 v2.0.0-alpha10 h1:uv/xz/d4SZAiZ22umWu31JT384k7nsyOpi9eiVBVfxA= -github.com/alecthomas/participle/v2 v2.0.0-alpha10/go.mod h1:RC764t6n4L8D8ITAJv0qdokritYSNR3wV5cVwmIEaMM= +github.com/alecthomas/participle/v2 v2.0.0-beta.5 h1:y6dsSYVb1G5eK6mgmy+BgI3Mw35a3WghArZ/Hbebrjo= +github.com/alecthomas/participle/v2 v2.0.0-beta.5/go.mod h1:RC764t6n4L8D8ITAJv0qdokritYSNR3wV5cVwmIEaMM= 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/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= 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/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= diff --git a/internal/route/parser.go b/internal/route/parser.go index 06cdc71..2f66a09 100644 --- a/internal/route/parser.go +++ b/internal/route/parser.go @@ -12,13 +12,12 @@ import ( // Parser is a BNF-based route syntax parser using stateful lexer. type Parser struct { - parser *participle.Parser + parser *participle.Parser[Route] } // Parse parses and returns a single route. func (p *Parser) Parse(s string) (*Route, error) { - ast := &Route{} - return ast, p.parser.ParseString("", s, ast) + return p.parser.ParseString("", s) } // NewParser creates and returns a new Parser. @@ -62,8 +61,7 @@ func NewParser() (*Parser, error) { return nil, errors.Wrap(err, "new lexer") } - parser, err := participle.Build( - &Route{}, + parser, err := participle.Build[Route]( participle.Lexer(l), participle.UseLookahead(2), )