Skip to content

Commit

Permalink
Upgrade Go compiler to v1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
nihei9 committed Aug 6, 2022
1 parent d45b860 commit 5da3885
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 32 deletions.
27 changes: 13 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,25 @@ on:

jobs:

build:
test:
name: go test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.16

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

golangci:
name: lint
lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
- uses: golangci/golangci-lint-action@v3
with:
version: latest
args: -E gofmt
4 changes: 2 additions & 2 deletions cmd/vartan-go/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"os"

mldriver "github.com/nihei9/maleeni/driver"
Expand Down Expand Up @@ -109,7 +109,7 @@ func readCompiledGrammar(path string) (*spec.CompiledGrammar, error) {
if err != nil {
return nil, err
}
data, err := ioutil.ReadAll(f)
data, err := io.ReadAll(f)
if err != nil {
return nil, err
}
Expand Down
21 changes: 10 additions & 11 deletions cmd/vartan/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -67,13 +66,13 @@ func runCompile(cmd *cobra.Command, args []string) (retErr error) {
return err
}

src, err := ioutil.ReadAll(os.Stdin)
src, err := io.ReadAll(os.Stdin)
if err != nil {
return err
}

grmPath = filepath.Join(tmpDirPath, "stdin.vartan")
err = ioutil.WriteFile(grmPath, src, 0600)
err = os.WriteFile(grmPath, src, 0600)
if err != nil {
return err
}
Expand Down Expand Up @@ -135,14 +134,14 @@ func readGrammar(path string) (grm *grammar.Grammar, retErr error) {
// writeCompiledGrammarAndReport writes a compiled grammar and a report to a files located at a specified path.
// This function selects one of the following output methods depending on how the path is specified.
//
// 1. When the path is a directory path, this function writes the compiled grammar and the report to
// <path>/<grammar-name>.json and <path>/<grammar-name>-report.json files, respectively.
// <grammar-name>-report.json as the output files.
// 2. When the path is a file path or a non-exitent path, this function asumes that the path represents a file
// path for the compiled grammar. Then it also writes the report in the same directory as the compiled grammar.
// The report file is named <grammar-name>.json.
// 3. When the path is an empty string, this function writes the compiled grammar to the stdout and writes
// the report to a file named <current-directory>/<grammar-name>-report.json.
// 1. When the path is a directory path, this function writes the compiled grammar and the report to
// <path>/<grammar-name>.json and <path>/<grammar-name>-report.json files, respectively.
// <grammar-name>-report.json as the output files.
// 2. When the path is a file path or a non-exitent path, this function asumes that the path represents a file
// path for the compiled grammar. Then it also writes the report in the same directory as the compiled grammar.
// The report file is named <grammar-name>.json.
// 3. When the path is an empty string, this function writes the compiled grammar to the stdout and writes
// the report to a file named <current-directory>/<grammar-name>-report.json.
func writeCompiledGrammarAndReport(cgram *spec.CompiledGrammar, report *spec.Report, path string) error {
cgramPath, reportPath, err := makeOutputFilePaths(cgram.Name, path)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/vartan/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"os"
"strings"

Expand Down Expand Up @@ -150,7 +150,7 @@ func readCompiledGrammar(path string) (*spec.CompiledGrammar, error) {
if err != nil {
return nil, err
}
data, err := ioutil.ReadAll(f)
data, err := io.ReadAll(f)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/vartan/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"strings"
"text/template"
Expand Down Expand Up @@ -46,7 +45,7 @@ func readReport(path string) (*spec.Report, error) {
}
defer f.Close()

d, err := ioutil.ReadAll(f)
d, err := io.ReadAll(f)
if err != nil {
return nil, err
}
Expand Down
7 changes: 6 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
module github.com/nihei9/vartan

go 1.16
go 1.19

require (
github.com/nihei9/maleeni v0.6.1
github.com/spf13/cobra v1.4.0
)

require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
)

0 comments on commit 5da3885

Please sign in to comment.