Skip to content
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

expected 'IDENT', found '/' #120

Open
OGKevin opened this issue Aug 4, 2019 · 2 comments
Open

expected 'IDENT', found '/' #120

OGKevin opened this issue Aug 4, 2019 · 2 comments

Comments

@OGKevin
Copy link
Contributor

OGKevin commented Aug 4, 2019

When generating a struct with 1 string field or any number of fields, i manage to get

4:9: expected 'IDENT', found '/'
error.

e.g.

type Show struct { 
 SomeString string
}

and then

//go:generate gojay -s $GOFILE -p true -t Show -o $GOFILE.gojay.go

On top of the file generates that error.

Any ideas what might be causing this?

@syllabix
Copy link

syllabix commented Aug 10, 2019

this error is returned from the call to the standard libs format.Source at line 123 in generator.go. If you provide a path including the filename to -s and do not specify what package the generated output should be in - gojay will output a package name that is invalid source code - effectively the full path to the directory the target file is in.

// Code generated by Gojay. DO NOT EDIT.
package /Users/myuser/go/src/github.com/foo/my-package

This does appear to be a bug and not user error as the -pkg flag is not required. That said - the workaround with the existing version is to provide a valid package name to the -pkg flag or not provide the filename to the -s flag and ensure that -o is set to the correct destination.

the bug itself appears to be at line 241 in generator.go where the output package name is not set correctly. happy to open a simple PR for this one if it is the case

@zorro786
Copy link

zorro786 commented Oct 7, 2020

Thank you @syllabix for the workaround!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants