Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can different custom packages for key and value is possible? #8

Open
sneko opened this issue Mar 9, 2021 · 1 comment
Open

Can different custom packages for key and value is possible? #8

sneko opened this issue Mar 9, 2021 · 1 comment

Comments

@sneko
Copy link

sneko commented Mar 9, 2021

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 ^^

@jamesrobb
Copy link

I can to ask essentially the same thing. It would be really nice to use custom types and having a means of unambiguously specifying said types (.e.g, by specifying the package name somehow).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants