Skip to content

cleanup commented code, golangci-lint fixes #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions endtoend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

// go command is not available on android

//go:build !android
// +build !android

package main
Expand All @@ -12,7 +13,6 @@ import (
"fmt"
"go/build"
"io"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -40,7 +40,7 @@ func init() {
// binary panics if the String method for X is not correct, including for error cases.

func TestEndToEnd(t *testing.T) {
dir, err := ioutil.TempDir("", "stringer")
dir, err := os.MkdirTemp("", "stringer")
if err != nil {
t.Fatal(err)
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module github.com/dmarkham/enumer

require (
github.com/pascaldekloe/name v1.0.0
golang.org/x/text v0.3.7
golang.org/x/tools v0.1.12
)

Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
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 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
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=
Expand Down
24 changes: 18 additions & 6 deletions golden_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package main

import (
"io/ioutil"
"io"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -360,7 +360,7 @@ func runGoldenTest(t *testing.T, test Golden,
file := test.name + ".go"
input := "package test\n" + test.input

dir, err := ioutil.TempDir("", "stringer")
dir, err := os.MkdirTemp("", "stringer")
if err != nil {
t.Error(err)
}
Expand All @@ -372,7 +372,7 @@ func runGoldenTest(t *testing.T, test Golden,
}()

absFile := filepath.Join(dir, file)
err = ioutil.WriteFile(absFile, []byte(input), 0644)
err = os.WriteFile(absFile, []byte(input), 0644)
if err != nil {
t.Error(err)
}
Expand All @@ -382,12 +382,24 @@ func runGoldenTest(t *testing.T, test Golden,
if len(tokens) != 3 {
t.Fatalf("%s: need type declaration on first line", test.name)
}
g.generate(tokens[1], generateJSON, generateYAML, generateSQL, generateText, generateGQLGen, "noop", trimPrefix, prefix, linecomment, generateValuesMethod)
g.generate(generateParams{
AddPrefix: prefix,
IncludeGQLGen: generateGQLGen,
IncludeJSON: generateJSON,
IncludeSQL: generateSQL,
IncludeText: generateText,
IncludeValuesMethod: generateValuesMethod,
IncludeYAML: generateYAML,
LineComment: linecomment,
TransformMethod: "noop",
TrimPrefix: trimPrefix,
TypeName: tokens[1],
})
got := string(g.format())
if got != loadGolden(test.name) {
// Use this to help build a golden text when changes are needed
//goldenFile := fmt.Sprintf("./testdata/%v.golden", test.name)
//err = ioutil.WriteFile(goldenFile, []byte(got), 0644)
//err = os.WriteFile(goldenFile, []byte(got), 0644)
//if err != nil {
// t.Error(err)
//}
Expand All @@ -401,7 +413,7 @@ func loadGolden(name string) string {
return ""
}
defer fh.Close()
b, err := ioutil.ReadAll(fh)
b, err := io.ReadAll(fh)
if err != nil {
return ""
}
Expand Down
Loading