Skip to content

Commit

Permalink
Less dependencies and update to go 1.19 (#136)
Browse files Browse the repository at this point in the history
* try less dependencies

* ioutil is replaced with os

* replace ioutil with os

* replace ioutil with os
  • Loading branch information
awalterschulze authored Feb 28, 2023
1 parent 2730a37 commit 2292f9e
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 95 deletions.
7 changes: 1 addition & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ ci-lint: ## see https://golangci-lint.run/, applies .golangci.yml

lint: govet ci-lint

goimports: ## sort and separate imports
go get golang.org/x/tools/cmd/goimports
goimports -l -w .

goclean: gofmt goimports ## apply go style rules to source
goclean: gofmt ## apply go style rules to source

regenerate: ## regenerate all example and test files
make install
Expand All @@ -41,7 +37,6 @@ check: ## regenerate, lint and run a terse version of check
@make --quiet -C internal/test regenerate
@# promote formatting changes to errors
@if [ -n "$(gofmt -l -s .)" ]; then { echo "gofmt errors:"; gofmt -d -l -s . ; exit 1; }; fi
@if [ -n "$(gomports -l . )" ]; then { echo "goimports errors:"; goimports -l . ; exit 1; }; fi
@make --quiet lint
@go test ./... | grep -v "\[no test"

Expand Down
4 changes: 2 additions & 2 deletions example/astx/lexer/lexer.go

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

4 changes: 2 additions & 2 deletions example/bools/lexer/lexer.go

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

4 changes: 2 additions & 2 deletions example/calc/lexer/lexer.go

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

4 changes: 2 additions & 2 deletions example/errormsg/lexer/lexer.go

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

4 changes: 2 additions & 2 deletions example/errorrecovery/lexer/lexer.go

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

4 changes: 2 additions & 2 deletions example/mail/lexer/lexer.go

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

4 changes: 2 additions & 2 deletions example/rr/lexer/lexer.go

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

4 changes: 2 additions & 2 deletions example/sr/lexer/lexer.go

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

4 changes: 2 additions & 2 deletions example/usercontext/lexer/lexer.go

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

8 changes: 2 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
module github.com/goccmack/gocc

go 1.12
go 1.19

require (
golang.org/x/mod v0.8.0
golang.org/x/tools v0.6.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)
require golang.org/x/mod v0.8.0
48 changes: 0 additions & 48 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,50 +1,2 @@
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.5.0 h1:+bSpV5HIeWkuvgaMfI3UmKRThoTA5ODJTUd8T17NO+4=
golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k=
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
3 changes: 1 addition & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"flag"
"fmt"
"go/build"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -260,7 +259,7 @@ func currentModule() (string, string, error) {
}

full := path.Join(parent, info.Name())
data, err := ioutil.ReadFile(full)
data, err := os.ReadFile(full)
if err != nil {
return "", "", fmt.Errorf("reading file '%s': %s", full, err)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/frontend/token/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package token
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -130,7 +130,7 @@ func (this *TokenMap) AddToken(str string) {
}

func NewMapFromFile(file string) (*TokenMap, error) {
src, err := ioutil.ReadFile(file)
src, err := os.ReadFile(file)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -214,5 +214,5 @@ func (this *TokenMap) WriteFile(file string) error {
for i := 1; i < len(this.tokenMap); i++ {
out += this.TokenString(Type(i)) + "\n"
}
return ioutil.WriteFile(file, []byte(out), 0644)
return os.WriteFile(file, []byte(out), 0644)
}
3 changes: 1 addition & 2 deletions internal/io/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package io

import (
"io/ioutil"
"os"
"path"
)
Expand All @@ -28,7 +27,7 @@ func WriteFile(fpath string, data []byte) {
if err := os.MkdirAll(dir, PermDir); err != nil {
panic(err)
}
if err := ioutil.WriteFile(fpath, data, PermFile); err != nil {
if err := os.WriteFile(fpath, data, PermFile); err != nil {
panic(err)
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/lexer/gen/golang/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ package lexer
import (
{{if .Debug}} "fmt"
{{end}} "io/ioutil"
{{end}} "os"
"unicode/utf8"
{{if .Debug}} "{{.UtilImport}}"
Expand Down Expand Up @@ -109,7 +109,7 @@ func (s *SourceContext) Source() string {
}
func NewLexerFile(fpath string) (*Lexer, error) {
src, err := ioutil.ReadFile(fpath)
src, err := os.ReadFile(fpath)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/test/t1/lexer/lexer.go

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

6 changes: 2 additions & 4 deletions internal/util/md/md.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ Package md extracts code sections of markdown files
*/
package md

import (
"io/ioutil"
)
import "os"

/*
GetSource returns code sections enclosed in triple backticks.
*/
func GetSource(mdfile string) (string, error) {
inbuf, err := ioutil.ReadFile(mdfile)
inbuf, err := os.ReadFile(mdfile)
if err != nil {
return "", err
}
Expand Down
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"os"
"path"
"strings"
Expand Down Expand Up @@ -119,7 +118,7 @@ func getSource(cfg config.Config) []byte {
}
return []byte(str)
}
srcBuffer, err := ioutil.ReadFile(cfg.SourceFile())
srcBuffer, err := os.ReadFile(cfg.SourceFile())
if err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down

0 comments on commit 2292f9e

Please sign in to comment.