Skip to content

Commit

Permalink
update dep
Browse files Browse the repository at this point in the history
  • Loading branch information
youthlin committed Jan 5, 2024
1 parent 5fc4bc1 commit 5d92dde
Show file tree
Hide file tree
Showing 17 changed files with 969 additions and 486 deletions.
2 changes: 1 addition & 1 deletion cmd/xtemplate/internal/keyword.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strconv"
"strings"

"github.com/cockroachdb/errors"
"github.com/youthlin/t"
"github.com/youthlin/t/errors"
)

// Keyword gettext keyword
Expand Down
2 changes: 1 addition & 1 deletion cmd/xtemplate/internal/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"strings"
"time"

"github.com/cockroachdb/errors"
"github.com/youthlin/t"
"github.com/youthlin/t/errors"
"github.com/youthlin/t/translator"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/xtemplate/internal/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"path/filepath"
"text/template/parse"

"github.com/cockroachdb/errors"
"github.com/youthlin/t"
"github.com/youthlin/t/errors"
"github.com/youthlin/t/translator"
)

Expand Down
23 changes: 23 additions & 0 deletions errors/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package errors

import (
"errors"
"fmt"
)

func Errorf(format string, args ...interface{}) error {
return fmt.Errorf(format, args...)
}

func Wrapf(err error, format string, args ...interface{}) error {
args = append(args, err)
return fmt.Errorf(format+": %w", args...)
}

func WithSecondaryError(err error, additionalErr error) error {
return fmt.Errorf("%w: %w", err, additionalErr)
}

func Is(err, target error) bool {
return errors.Is(err, target)
}
24 changes: 9 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,17 @@ module github.com/youthlin/t
go 1.17

require (
github.com/Xuanwo/go-locale v1.0.0
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210803070921-b358b509191a
github.com/cockroachdb/errors v1.8.6
github.com/smartystreets/goconvey v1.6.4
golang.org/x/text v0.3.7
github.com/Xuanwo/go-locale v1.1.0
github.com/antlr4-go/antlr/v4 v4.13.0
github.com/smartystreets/goconvey v1.8.1
golang.org/x/text v0.14.0
)

require (
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect
github.com/cockroachdb/redact v1.1.1 // indirect
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect
github.com/smarty/assertions v1.15.0 // indirect
github.com/stretchr/testify v1.8.1 // indirect
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
golang.org/x/sys v0.6.0 // indirect
)
661 changes: 480 additions & 181 deletions go.sum

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions plurals/err.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package plurals
import (
"fmt"

"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/cockroachdb/errors"
"github.com/antlr4-go/antlr/v4"

Check failure on line 6 in plurals/err.go

View workflow job for this annotation

GitHub Actions / build

//go:build comment without // +build comment
"github.com/youthlin/t/errors"
)

// ErrAntlr is a error when antlr process fails
Expand All @@ -20,15 +20,15 @@ func (d *errorListener) SyntaxError(recognizer antlr.Recognizer, offendingSymbol
d.addError(errors.Errorf("SyntaxError(line %v:%v): %v", line, column, msg)) // SyntaxError 语法错误
}

func (d *errorListener) ReportAmbiguity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, exact bool, ambigAlts *antlr.BitSet, configs antlr.ATNConfigSet) {
func (d *errorListener) ReportAmbiguity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, exact bool, ambigAlts *antlr.BitSet, configs *antlr.ATNConfigSet) {
d.addError(errors.Errorf("ReportAmbiguity")) // Ambiguity 歧义
}

func (d *errorListener) ReportAttemptingFullContext(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, conflictingAlts *antlr.BitSet, configs antlr.ATNConfigSet) {
func (d *errorListener) ReportAttemptingFullContext(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, conflictingAlts *antlr.BitSet, configs *antlr.ATNConfigSet) {
d.addError(errors.Errorf("ReportAttemptingFullContext")) // SLL 冲突
}

func (d *errorListener) ReportContextSensitivity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex, prediction int, configs antlr.ATNConfigSet) {
func (d *errorListener) ReportContextSensitivity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex, prediction int, configs *antlr.ATNConfigSet) {
d.addError(errors.Errorf("ReportContextSensitivity")) // 上下文相关
}

Expand Down
4 changes: 2 additions & 2 deletions plurals/err_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import (
"fmt"
"testing"

"github.com/cockroachdb/errors"
. "github.com/smartystreets/goconvey/convey"
"github.com/youthlin/t/errors"
)

func Test_errorListener_addError(t *testing.T) {
Convey("add-err", t, func() {
var err = errors.Errorf("abc=%v", 1)
e := new(errorListener)
e.addError(fmt.Errorf("fmt-error"))
e.addError(errors.New("errors-new"))
e.addError(errors.Errorf("errors-new"))
e.addError(errors.Wrapf(err, "wrap message"))
t.Logf("err=%+v", e.err)
})
Expand Down
6 changes: 3 additions & 3 deletions plurals/exp.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strconv"
"strings"

"github.com/antlr/antlr4/runtime/Go/antlr"
"github.com/cockroachdb/errors"
"github.com/antlr4-go/antlr/v4"
"github.com/youthlin/t/errors"
"github.com/youthlin/t/plurals/parser"
)

Expand Down Expand Up @@ -41,7 +41,7 @@ func Eval(ctx context.Context, exp string, n int64) (result int64, err error) {

// 4 遍历语法树计算表达式
l := newListener(ctx, n)
tree := p.Start()
tree := p.Start_()
antlr.ParseTreeWalkerDefault.Walk(l, tree)
return l.result, errListener.err
}
Expand Down
4 changes: 2 additions & 2 deletions plurals/parser/plural_base_listener.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5d92dde

Please sign in to comment.