Skip to content

Commit

Permalink
Merge pull request #75 from Teamwork/fix/predeclared-types
Browse files Browse the repository at this point in the history
Fix: Add missing predeclared types
  • Loading branch information
rafaeljusto authored Apr 27, 2023
2 parents c8e4d01 + 3227d6b commit 59f924d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions goutil/goutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func ResolvePackage(path string, mode build.ImportMode) (pkg *build.Package, err
if err != nil {
return nil, err
}
fmt.Println(path)
pkg, err = build.ImportDir(path, mode)
default:
if cwd == "" {
Expand Down Expand Up @@ -266,7 +265,7 @@ start:
// https://golang.org/ref/spec#Predeclared_identifiers
func PredeclaredType(n string) bool {
switch n {
case "bool", "byte", "complex64", "complex128", "error", "float32",
case "any", "bool", "byte", "comparable", "complex64", "complex128", "error", "float32",
"float64", "int", "int8", "int16", "int32", "int64", "rune", "string",
"uint", "uint8", "uint16", "uint32", "uint64", "uintptr":
return true
Expand Down
8 changes: 4 additions & 4 deletions goutil/goutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func TestTagName(t *testing.T) {
for _, tc := range cases {
t.Run(fmt.Sprintf("%v", tc.in), func(t *testing.T) {
f := &ast.Field{
Names: []*ast.Ident{&ast.Ident{Name: "Original"}},
Names: []*ast.Ident{{Name: "Original"}},
Tag: &ast.BasicLit{Value: fmt.Sprintf("`%v`", tc.in)}}

out := TagName(f, tc.inName)
Expand All @@ -239,7 +239,7 @@ func TestTagName(t *testing.T) {

t.Run("nil", func(t *testing.T) {
f := &ast.Field{
Names: []*ast.Ident{&ast.Ident{Name: "Original"}},
Names: []*ast.Ident{{Name: "Original"}},
}

out := TagName(f, "json")
Expand All @@ -260,8 +260,8 @@ func TestTagName(t *testing.T) {
}()

f := &ast.Field{
Names: []*ast.Ident{&ast.Ident{Name: "Original"},
&ast.Ident{Name: "Second"}}}
Names: []*ast.Ident{{Name: "Original"},
{Name: "Second"}}}
_ = TagName(f, "json")
})

Expand Down

0 comments on commit 59f924d

Please sign in to comment.