From 5da388521510b839406b6232748bc669cda97dec Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Sun, 7 Aug 2022 00:59:50 +0900 Subject: Upgrade Go compiler to v1.19 --- .github/workflows/test.yml | 27 +++++++++++++-------------- cmd/vartan-go/generate.go | 4 ++-- cmd/vartan/compile.go | 21 ++++++++++----------- cmd/vartan/parse.go | 4 ++-- cmd/vartan/show.go | 3 +-- go.mod | 7 ++++++- 6 files changed, 34 insertions(+), 32 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5c595df..ca0c729 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/cmd/vartan-go/generate.go b/cmd/vartan-go/generate.go index 8ae4db5..13ba5c0 100644 --- a/cmd/vartan-go/generate.go +++ b/cmd/vartan-go/generate.go @@ -3,7 +3,7 @@ package main import ( "encoding/json" "fmt" - "io/ioutil" + "io" "os" mldriver "github.com/nihei9/maleeni/driver" @@ -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 } diff --git a/cmd/vartan/compile.go b/cmd/vartan/compile.go index eb25374..49e383d 100644 --- a/cmd/vartan/compile.go +++ b/cmd/vartan/compile.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "os" "path/filepath" @@ -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 } @@ -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 -// /.json and /-report.json files, respectively. -// -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 .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 /-report.json. +// 1. When the path is a directory path, this function writes the compiled grammar and the report to +// /.json and /-report.json files, respectively. +// -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 .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 /-report.json. func writeCompiledGrammarAndReport(cgram *spec.CompiledGrammar, report *spec.Report, path string) error { cgramPath, reportPath, err := makeOutputFilePaths(cgram.Name, path) if err != nil { diff --git a/cmd/vartan/parse.go b/cmd/vartan/parse.go index 3f895c9..ed35a60 100644 --- a/cmd/vartan/parse.go +++ b/cmd/vartan/parse.go @@ -3,7 +3,7 @@ package main import ( "encoding/json" "fmt" - "io/ioutil" + "io" "os" "strings" @@ -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 } diff --git a/cmd/vartan/show.go b/cmd/vartan/show.go index 547facf..328f483 100644 --- a/cmd/vartan/show.go +++ b/cmd/vartan/show.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "os" "strings" "text/template" @@ -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 } diff --git a/go.mod b/go.mod index 6b466b4..5eec6bf 100644 --- a/go.mod +++ b/go.mod @@ -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 +) -- cgit v1.2.3