Skip to content

Commit

Permalink
fix builds (#2)
Browse files Browse the repository at this point in the history
* parcer rules break go's understanding on the right usage

* go build in ci demands no patch number in the version

* go build - deps require 1.21 at least, let's make it 1.22

* golang-ci lint action

* add golangci config with basic rules

* cleanup or whitelist printlns
  • Loading branch information
can3p authored Apr 14, 2024
1 parent bee2361 commit 63cc295
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,25 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.22'

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...

golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
# from: https://github.com/marketplace/actions/run-golangci-lint
version: latest
20 changes: 20 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
linters:
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- forbidigo

linters-settings:
forbidigo:
# Forbid the following identifiers (list of regexp).
# Default: ["^(fmt\\.Print(|f|ln)|print|println)$"]
forbid:
# Builtin function:
- ^print.*$
# Optional message that gets included in error reports.
- p: ^fmt\.Print.*$
msg: Do not commit print statements.
1 change: 1 addition & 0 deletions cmd/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func ModCommand() *cobra.Command {
return err
}

// nolint:forbidigo
fmt.Print(string(out))

return nil
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/can3p/sackmesser

go 1.22.0
go 1.22

require (
github.com/alecthomas/assert/v2 v2.8.1
Expand Down
2 changes: 2 additions & 0 deletions pkg/operations/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ var operations = map[string]Operation{
"del": Delete,
}

//nolint:govet
type Call struct {
Name string `@Ident`
Path []PathElement `"(" (@Ident | @String ) ( "." (@Ident | @String) )*`
Arguments []Argument `( "," @@ )* ")"`
}

//nolint:govet
type Argument struct {
Float *float64 ` @Float`
Int *int `| @Int`
Expand Down
5 changes: 2 additions & 3 deletions pkg/traverse/simpleyaml/simpleyaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package simpleyaml

import (
"fmt"
"gopkg.in/yaml.v3"
"reflect"
"strconv"

"gopkg.in/yaml.v3"

"github.com/can3p/sackmesser/pkg/traverse/types"
)

Expand Down Expand Up @@ -165,8 +166,6 @@ func (n *jnode) NodeType() types.NodeType {
return types.NodeTypeNull
}

fmt.Println(n.vType.Kind())

switch n.vType.Kind() {
case reflect.Bool:
return types.NodeTypeBool
Expand Down

0 comments on commit 63cc295

Please sign in to comment.