Can different custom packages for key and value is possible?
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Domain
- tooling
Research direction
Look at the syncmap code generator to understand how it currently handles types and imports. The issue is about supporting custom types from different packages for keys and values. Start by examining the parsing of the map type string and the import management. Check if there are existing tests for custom types. The goal is to modify the generator to add necessary imports and handle type references across packages without causing circular dependencies.
Written by the indexing model from the issue text.
Description
Hi @a8m ,
Currently using a basic
syncmap -name UserChannelsMap -pkg xmap -o ./types/xmap/user_channels_map.go "map[string]string"
will work.
If I want to use a custom type:
syncmap -name UserChannelsMap -pkg xmap -o ./types/xmap/user_channels_map.go "map[string]*UserChannelList"
I need to make sure UserChannelList is in the same package than the one exported for the file (here xmap). I could arrange myself to do so, but it brings some complexity.
Last case, I want to use like an "enum" for the keys, in my case it's defined in my own constant package, how could I deal with this? From what I understand it's not possible, the syncmap would have to manage some add of imports, no?
syncmap -name UserChannelsMap -pkg xmap -o ./types/xmap/user_channels_map.go "map[constant.NameID]*UserChannelList"
Maybe I missed something 🤔
Thank you,
EDIT: a workaround could be that aside my exported file (having package xmap) I could declare type aliases for both the key and the value types, like:
import ...
type NameID = constant.NameID
type UserChannelList = entity.UserChannelList
EDIT2: in all cases, I should make sure it won't bring circular loop if the XXXMap was needed in one of those packages ^^
- Dominant language
- Go
- Stars
- 257
- Forks
- 17
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from a8m/syncmap
-
Fails with errorOpen
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 40/100
-
GetValues & GetKeysOpen
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
google/differential-privacy#516 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
lightninglabs/lndmon#140 ·
-
documentation good first issue ready-for-triage ready-to-code
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
release-engineering/fbc-update-planner#102 · 3 comments ·
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
yetone/magpie#562 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 4 days