# Auto generated package names?

**URL:** <https://community.haxe.org/t/auto-generated-package-names/3308>\
**Category:** Haxe\
**Created:** [October 27, 2021, 4:55pm UTC](https://community.haxe.org/t/auto-generated-package-names/3308 "2021-10-27T16:55:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lelelo1](https://avatars.discourse-cdn.com/v2/letter/l/9f8e36/32.png) [@Lelelo1](https://community.haxe.org/u/Lelelo1)\
**Post date:** [October 27, 2021, 4:55pm UTC](https://community.haxe.org/t/auto-generated-package-names/3308/1 "2021-10-27T16:55:19Z")

</div>

It seems like it is possible to set the package name wrong relative to file structure.

Say I have _src_ folder. Then I create _models_ folder inside and place a file there. In that file I am able to set any package name. It will generate complaints when using it outside the file but there is no complaint when giving the package name

I thought this was a bug at times. I have been programming with flutter in dart a bit as well - so I might have gotten used to auto generated package names.

It seem you can set any package name but that there only is one acceptable package name? But there could also be something I have missed about this.

---

<div class="post-metadata">

**Author:** ![Geokureli](https://community.haxe.org/user_avatar/community.haxe.org/geokureli/32/256_2.png) [@Geokureli](https://community.haxe.org/u/Geokureli)\
**Post date:** [October 27, 2021, 5:40pm UTC](https://community.haxe.org/t/auto-generated-package-names/3308/2 "2021-10-27T17:40:26Z")

</div>

vscode and many other IDEs autogenerate packages for newly created haxe classes

---

<div class="post-metadata">

**Author:** ![Lelelo1](https://avatars.discourse-cdn.com/v2/letter/l/9f8e36/32.png) [@Lelelo1](https://community.haxe.org/u/Lelelo1)\
**Post date:** [October 27, 2021, 6:09pm UTC](https://community.haxe.org/t/auto-generated-package-names/3308/3 "2021-10-27T18:09:07Z")

</div>

I had `src.models.Person`.  
When creating new file `MyClass` - placing it in the same folder I got `package models;` autogenerated.  
So the intelligence was saying both are valid.  
Before I had to prepend `src.*` to my Person file to make it work. Now I could change to `models.*` for both files  
This has happened several times before. I don’t know what triggers its, changing target? I think I have deleted the folder and created new files at some times and pasting in the code  
These are just dummy simple classes not importing anything.

It might be some underlaying bug.

---

<div class="post-metadata">

**Author:** ![Geokureli](https://community.haxe.org/user_avatar/community.haxe.org/geokureli/32/256_2.png) [@Geokureli](https://community.haxe.org/u/Geokureli)\
**Post date:** [November 2, 2021, 4:20pm UTC](https://community.haxe.org/t/auto-generated-package-names/3308/4 "2021-11-02T16:20:00Z")

</div>

typically the src folder is the root, and not a package folder. you can make it a package if you set the root to the parent folder, but that seems like an odd choice

---

<div class="post-metadata">

**Author:** ![Lelelo1](https://avatars.discourse-cdn.com/v2/letter/l/9f8e36/32.png) [@Lelelo1](https://community.haxe.org/u/Lelelo1)\
**Post date:** [November 3, 2021, 4:34pm UTC](https://community.haxe.org/t/auto-generated-package-names/3308/5 "2021-11-03T16:34:06Z")

</div>

None of the files in _src_ had package declared

---

<div class="post-metadata">

**Author:** ![Geokureli](https://community.haxe.org/user_avatar/community.haxe.org/geokureli/32/256_2.png) [@Geokureli](https://community.haxe.org/u/Geokureli)\
**Post date:** [November 4, 2021, 6:39pm UTC](https://community.haxe.org/t/auto-generated-package-names/3308/6 "2021-11-04T18:39:17Z")

</div>

> None of the files in _src_ had package declared

yeah, you can omit package in toplevel files. that is, you can omit `package;` when it is empty, like that. this further suggests that src is not a package, therefore packages like `src.models.Person` should just be `models.Person`.

> So the intelligence was saying both are valid.

both shouldn’t be valid. are you getting any compile errors?

---

<div class="post-metadata">

**Author:** ![Lelelo1](https://avatars.discourse-cdn.com/v2/letter/l/9f8e36/32.png) [@Lelelo1](https://community.haxe.org/u/Lelelo1)\
**Post date:** [November 6, 2021, 12:06pm UTC](https://community.haxe.org/t/auto-generated-package-names/3308/7 "2021-11-06T12:06:38Z")

</div>

I was trying to reproduce this.

I noticed that package declaration doesn’t update when the files are moved. It could have been what started the issue for me originally.

 ![Screen Shot 2021-11-06 at 12.58.24](https://community.haxe.org/uploads/default/original/2X/f/ff527a160bc68ce73b81bc89d85ec76d5f6aaa18.png)

The _Hello_ file was created in _src_ which generated no package declaration. Then I moved it into _models_ folder. There I had to manually add `package models;`. It compiled.  
Then moving it out into _src_ again it still compiles.

I think I might gotten out of sync from this and also typed wrong package name at some point.

* * *

What I am used to in flutter is that package name plays always sticks to the file’s location and they update when being moved across folders
