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
Presently the "package" is required in each go file. The package dictates the name of the library when imported somewhere else. Often it matches the directory name of the package but not always. In these cases when a library is imported this defined package must be used to call the code from this library instead of the name of the directory.
I think the package keyword should be made optional, only for backwards compatibility, and the directory of the go files should be assumed as package name automatically. This will allow us to simplify refactoring(just rename a directory instead of all uses of the package keyword in that directory), plus it will simplify refactoring imports - there will no longer be a need to scan the imported library and look for the package name, instead the directory name will be used right away. If two packages with the same directory are imported, import aliasing still works like before.
Some may say that package keyword is required for the build functionality, but I think that, since main() is a magic function name, whenever a package contains this method, it should be automatically assumed it is the main package(build/functionality-wise, not name-wise..unless the directory is called main, of course) and can be compiled into executable and does not have to be specifically named as main.
The text was updated successfully, but these errors were encountered:
Presently the "package" is required in each go file. The package dictates the name of the library when imported somewhere else. Often it matches the directory name of the package but not always. In these cases when a library is imported this defined package must be used to call the code from this library instead of the name of the directory.
For example:
vs
I think the package keyword should be made optional, only for backwards compatibility, and the directory of the go files should be assumed as package name automatically. This will allow us to simplify refactoring(just rename a directory instead of all uses of the package keyword in that directory), plus it will simplify refactoring imports - there will no longer be a need to scan the imported library and look for the package name, instead the directory name will be used right away. If two packages with the same directory are imported, import aliasing still works like before.
Some may say that package keyword is required for the build functionality, but I think that, since
main()
is a magic function name, whenever a package contains this method, it should be automatically assumed it is the main package(build/functionality-wise, not name-wise..unless the directory is called main, of course) and can be compiled into executable and does not have to be specifically named as main.The text was updated successfully, but these errors were encountered: