You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Package and Name fields of *ast.File struct are a bit confusing.
It was an effort just to get the name of Package of a *ast.Field object because I thought *.ast.File.Name will be the name of the file. It was so obvious that I didn’t though of looking at the comments.
Thanks to Rui Santos for helping me out. Later I saw it was written in comments Name is Package name, not the file name.
What did you expect to see?
Instead of Name, something like PkgName would be better because it contains the package name of that file.
Instead of Package, maybe PkgPos can be more helpful name because it contains token Pos.
What did you see instead?
*ast.File.Name field containing the package name of the file is not intuitive.
*ast.File.Package field contains a Pos of package, so it's difficult to understand .
If it's there, I guess there must be some reason to name those fields like that, what I am unaware of.
But it was confusing for me.
Even if we decide to rename the fields, i think it won’t be that straight forward because it will start breaking the older versions.
What version of Go are you using (
go version
)?go version go1.13.4 darwin/amd64
What did you do?
The
Package
andName
fields of*ast.File
struct are a bit confusing.It was an effort just to get the name of Package of a
*ast.Field
object because I thought*.ast.File.Name
will be the name of the file. It was so obvious that I didn’t though of looking at the comments.Thanks to Rui Santos for helping me out. Later I saw it was written in comments
Name
is Package name, not the file name.What did you expect to see?
Name
, something likePkgName
would be better because it contains the package name of that file.Package
, maybePkgPos
can be more helpful name because it contains tokenPos
.What did you see instead?
*ast.File.Name
field containing the package name of the file is not intuitive.*ast.File.Package
field contains aPos
of package, so it's difficult to understand .If it's there, I guess there must be some reason to name those fields like that, what I am unaware of.
But it was confusing for me.
Even if we decide to rename the fields, i think it won’t be that straight forward because it will start breaking the older versions.
Please share your thoughts.
/cc @rsc @griesemer
The text was updated successfully, but these errors were encountered: