diff --git a/renovate.json b/.github/renovate.json similarity index 100% rename from renovate.json rename to .github/renovate.json diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml index f31ac65..ae7b71b 100644 --- a/.github/workflows/golangci-lint.yaml +++ b/.github/workflows/golangci-lint.yaml @@ -13,12 +13,12 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.20' - cache: false + go-version: stable + cache-dependency-path: go/go.sum - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: install-mode: "goinstall" - version: latest + version: v1.59 working-directory: go args: --config="${GITHUB_WORKSPACE}/go/.golangci.yaml" diff --git a/go/cmd/glox/glox_test.go b/go/cmd/glox/glox_test.go index cdd3df4..1a8e066 100644 --- a/go/cmd/glox/glox_test.go +++ b/go/cmd/glox/glox_test.go @@ -17,7 +17,7 @@ const TestDirectory = "../../../test/" func TestRunFile(t *testing.T) { t.Parallel() - err := filepath.WalkDir(TestDirectory, func(path string, d fs.DirEntry, err error) error { + err := filepath.WalkDir(TestDirectory, func(path string, _ fs.DirEntry, _ error) error { pattern := regexp.MustCompile("^.*expect: (.*)$") t.Run(path, func(t *testing.T) { diff --git a/go/go.mod b/go/go.mod index f0058ab..c6dece6 100644 --- a/go/go.mod +++ b/go/go.mod @@ -1,6 +1,6 @@ module github.com/fpotier/lox/go -go 1.20 +go 1.21 require github.com/sean-/sysexits v1.0.0 diff --git a/go/pkg/ast/loxvalue.go b/go/pkg/ast/loxvalue.go index bf3f73a..5ecea9a 100644 --- a/go/pkg/ast/loxvalue.go +++ b/go/pkg/ast/loxvalue.go @@ -1,6 +1,9 @@ package ast -import "fmt" +import ( + "fmt" + "strconv" +) type Kind uint8 @@ -35,7 +38,7 @@ func NewBooleanValue(v bool) *BooleanValue { } func (b BooleanValue) Kind() Kind { return Boolean } func (b BooleanValue) IsTruthy() bool { return b.Value } -func (b BooleanValue) String() string { return fmt.Sprintf("%v", b.Value) } +func (b BooleanValue) String() string { return strconv.FormatBool(b.Value) } func (b BooleanValue) Equals(v LoxValue) bool { if v, ok := v.(*BooleanValue); ok { return b.Value == v.Value diff --git a/go/pkg/ast/visitor.go b/go/pkg/ast/visitor.go index 314f87c..6a2e1a0 100644 --- a/go/pkg/ast/visitor.go +++ b/go/pkg/ast/visitor.go @@ -9,26 +9,26 @@ type Statement interface { } type Visitor interface { - VisitAssignmentExpression(*AssignmentExpression) - VisitBinaryExpression(*BinaryExpression) - VisitCallExpression(*CallExpression) - VisitGetExpression(*GetExpression) - VisitGroupingExpression(*GroupingExpression) - VisitLiteralExpression(*LiteralExpression) - VisitLogicalExpression(*LogicalExpression) - VisitSetExpression(*SetExpression) - VisitSuperExpression(*SuperExpression) - VisitThisExpression(*ThisExpression) - VisitUnaryExpression(*UnaryExpression) - VisitVariableExpression(*VariableExpression) + VisitAssignmentExpression(assignementExpression *AssignmentExpression) + VisitBinaryExpression(binaryExpression *BinaryExpression) + VisitCallExpression(callExpression *CallExpression) + VisitGetExpression(getExpression *GetExpression) + VisitGroupingExpression(groupingExpression *GroupingExpression) + VisitLiteralExpression(literalExpression *LiteralExpression) + VisitLogicalExpression(logicalExpression *LogicalExpression) + VisitSetExpression(setExpression *SetExpression) + VisitSuperExpression(superExpression *SuperExpression) + VisitThisExpression(thisExpression *ThisExpression) + VisitUnaryExpression(unaryExpression *UnaryExpression) + VisitVariableExpression(variableExpression *VariableExpression) - VisitBlockStatement(*BlockStatement) - VisitClassStatement(*ClassStatement) - VisitExpressionStatement(*ExpressionStatement) - VisitFunctionStatement(*FunctionStatement) - VisitIfStatement(*IfStatement) - VisitPrintStatement(*PrintStatement) - VisitReturnStatement(*ReturnStatement) - VisitVariableStatement(*VariableStatement) - VisitWhileStatement(*WhileStatement) + VisitBlockStatement(blockStatement *BlockStatement) + VisitClassStatement(classStatement *ClassStatement) + VisitExpressionStatement(expressionStatement *ExpressionStatement) + VisitFunctionStatement(functionStatement *FunctionStatement) + VisitIfStatement(ifStatement *IfStatement) + VisitPrintStatement(printStatement *PrintStatement) + VisitReturnStatement(returnStatement *ReturnStatement) + VisitVariableStatement(variableStatement *VariableStatement) + VisitWhileStatement(whileStatement *WhileStatement) } diff --git a/go/pkg/lexer/token.go b/go/pkg/lexer/token.go index 6aa6f80..624eedf 100644 --- a/go/pkg/lexer/token.go +++ b/go/pkg/lexer/token.go @@ -25,7 +25,7 @@ func (t *Token) String() string { return fmt.Sprintf("%v (value:%v)", tokenRepresentation[t.Type], t.Literal.String()) } - return fmt.Sprintf("%v", tokenRepresentation[t.Type]) + return tokenRepresentation[t.Type] } const ( diff --git a/go/pkg/runtime/loxcallable.go b/go/pkg/runtime/loxcallable.go index 22d36c6..78df481 100644 --- a/go/pkg/runtime/loxcallable.go +++ b/go/pkg/runtime/loxcallable.go @@ -3,7 +3,7 @@ package runtime import "github.com/fpotier/lox/go/pkg/ast" type LoxCallable interface { - Call(*Interpreter, []ast.LoxValue) ast.LoxValue + Call(interpreter *Interpreter, arguments []ast.LoxValue) ast.LoxValue Arity() int }