go version)?go version go1.13.4 darwin/amd64
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鈥檛 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.
Name, something like PkgName would be better because it contains the package name of that file.Package, maybe PkgPos can be more helpful name because it contains token Pos.*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鈥檛 be that straight forward because it will start breaking the older versions.
Please share your thoughts.
/cc @rsc @griesemer
They may be bad choices, but any change now would break the Go 1 compatibility guarantee (https://golang.org/doc/go1compat).
Based on 馃憤 from the OP closing as answered.
Most helpful comment
They may be bad choices, but any change now would break the Go 1 compatibility guarantee (https://golang.org/doc/go1compat).